Iphone 设备上未显示模式视图
我在iphone应用程序中使用模态视图。问题是这些视图在模拟器上工作,但当我在设备上安装它时,它会显示一个白色的空白屏幕,而不是模式视图。以前有人遇到过这个问题吗?我如何解决这个问题?下面是代码Iphone 设备上未显示模式视图,iphone,device,modal-view,Iphone,Device,Modal View,我在iphone应用程序中使用模态视图。问题是这些视图在模拟器上工作,但当我在设备上安装它时,它会显示一个白色的空白屏幕,而不是模式视图。以前有人遇到过这个问题吗?我如何解决这个问题?下面是代码 #import "ResetPWD.h" #import "WebServiceController.h" #import "ProductAppDelegate.h" @implementation ResetPWD @synthesize oldPWD; @synthesize newPWD;
#import "ResetPWD.h"
#import "WebServiceController.h"
#import "ProductAppDelegate.h"
@implementation ResetPWD
@synthesize oldPWD;
@synthesize newPWD;
@synthesize newPWD2;
@synthesize password1;
@synthesize password2;
-(IBAction)done:(id)sender {
NSString *pwd = oldPWD.text;
NSString *pwd1 = newPWD.text;
NSString *pwd2 = newPWD2.text;
if(!self.oldPWD.text )
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Please Enter Old Password."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
return;
}
if(!self.newPWD.text )
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Please Enter New Password."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
return;
}
if ([pwd1 length]<6) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"New password should be atleast 6 characters long" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
return;
}
if (![pwd1 isEqualToString:pwd2]) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Passwords do not match" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
return;
}
password1 = pwd;
password2 = pwd1;
NSMutableArray *data = [[NSMutableArray alloc]init];
[data addObject:password1];
[data addObject:password2];
WebServiceController *webCall = [[WebServiceController alloc]init];
NSDictionary *dict = [webCall resetPWD:data];
NSString * nVal = [dict objectForKey:@"ErrorCode"];
NSString *errorDesc = [dict objectForKey:@"ErrorType"];
NSString *errorString = [dict objectForKey:@"ErrorString"];
int n=[nVal integerValue];
if(n>=3)
{
errorString=[[NSString alloc]initWithFormat:@"%@\nProceed to broker registration.",errorString];
}
UIAlertView *successAlert=[[UIAlertView alloc]initWithTitle:errorDesc message:errorString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[successAlert show];
[successAlert release];
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
-(IBAction)cancel:(id)sender {
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
CGRect textFieldRect =
[self.view.window convertRect:textField.bounds fromView:textField];
CGRect viewRect =
[self.view.window convertRect:self.view.bounds fromView:self.view];
CGFloat midline = textFieldRect.origin.y + 0.5 * textFieldRect.size.height;
//if (textField == usernameField)
// midline+=20;
CGFloat numerator = midline - viewRect.origin.y - MINIMUM_SCROLL_FRACTION * viewRect.size.height;
CGFloat denominator = (MAXIMUM_SCROLL_FRACTION - MINIMUM_SCROLL_FRACTION) * viewRect.size.height;
CGFloat heightFraction = numerator / denominator;
if (heightFraction < 0.0)
{
heightFraction = 0.0;
}
else if (heightFraction > 1.0)
{
heightFraction = 1.0;
}
animatedDistance = floor(PORTRAIT_KEYBOARD_HEIGHT * heightFraction);
CGRect viewFrame = self.view.frame;
viewFrame.origin.y -= animatedDistance;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
[self.view setFrame:viewFrame];
[UIView commitAnimations];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
CGRect viewFrame = self.view.frame;
viewFrame.origin.y += animatedDistance;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
[self.view setFrame:viewFrame];
[UIView commitAnimations];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
// the user pressed the "Done" button, so dismiss the keyboard
[textField resignFirstResponder];
return NO;
}
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
}
return self;
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
#导入“ResetPWD.h”
#导入“WebServiceController.h”
#导入“ProductAppDelegate.h”
@实施重置PWD
@合成oldPWD;
@合成新的pwd;
@合成新的pwd2;
@合成密码1;
@合成密码2;
-(iAction)完成:(id)发送方{
NSString*pwd=oldPWD.text;
NSString*pwd1=newPWD.text;
NSString*pwd2=newPWD2.text;
如果(!self.oldPWD.text)
{
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@“消息:@”请输入旧密码
代表:自我取消按钮:@“确定”其他按钮:无];
[警报显示];
[警报发布];
回来
}
如果(!self.newPWD.text)
{
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@“消息:@”请输入新密码
代表:自我取消按钮:@“确定”其他按钮:无];
[警报显示];
[警报发布];
回来
}
如果([pwd1长度]=3)
{
errorString=[[NSString alloc]initWithFormat:@“%@\n已处理到代理注册。”,errorString];
}
UIAlertView*successAlert=[[UIAlertView alloc]initWithTitle:errorDesc消息:errorString委托:nil CancelButtontTitle:@“确定”其他ButtontTitles:nil];
[成功者秀];
[成功释放];
[self.parentViewController dismissModalViewControllerAnimated:是];
}
-(iAction)取消:(id)发件人{
[self.parentViewController dismissModalViewControllerAnimated:是];
}
-(无效)textFieldDidBeginEditing:(UITextField*)textField{
CGRect textFieldRect=
[self.view.window convertRect:textField.bounds fromView:textField];
CGRect viewRect=
[self.view.window convertRect:self.view.fromView:self.view];
CGFloat midline=textFieldRect.origin.y+0.5*textFieldRect.size.height;
//if(textField==usernameField)
//中线+=20;
CGFloat分子=中线-viewRect.origin.y-最小滚动分数*viewRect.size.height;
CGFloat分母=(最大滚动分数-最小滚动分数)*viewRect.size.height;
CGFloat heightFraction=分子/分母;
如果(高度分数<0.0)
{
高度分数=0.0;
}
否则如果(高度分数>1.0)
{
高度分数=1.0;
}
动画距离=地板(纵向\键盘\高度*高度分数);
CGRect viewFrame=self.view.frame;
viewFrame.origin.y-=动画距离;
[UIView beginAnimations:nil上下文:NULL];
[UIView setAnimationBeginsFromCurrentState:是];
[UIView设置动画持续时间:键盘动画持续时间];
[self.view setFrame:viewFrame];
[UIView委员会];
}
-(void)textfielddidediting:(UITextField*)textField
{
CGRect viewFrame=self.view.frame;
viewFrame.origin.y+=动画距离;
[UIView beginAnimations:nil上下文:NULL];
[UIView setAnimationBeginsFromCurrentState:是];
[UIView设置动画持续时间:键盘动画持续时间];
[self.view setFrame:viewFrame];
[UIView委员会];
}
-(BOOL)textField应返回:(UITextField*)textField
{
//用户按下“完成”按钮,因此关闭键盘
[textField resignFirstResponder];
返回否;
}
//指定的初始值设定项。如果以编程方式创建控制器并希望执行不适用于viewDidLoad的自定义,请重写。
/*
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化。
}
回归自我;
}
*/
/*
//实现viewDidLoad以在加载视图(通常从nib)后执行附加设置。
-(无效)viewDidLoad{
[超级视图下载];
}
*/
/*
//替代以允许默认纵向方向以外的方向。
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation{
//对于支持的方向,返回YES。
返回(interfaceOrientation==UIInterfaceOrientationGraphic);
}
*/
-(无效)未收到记忆警告{
//如果视图没有superview,则释放该视图。
[超级记忆警告];
//释放所有未使用的缓存数据、图像等。
}
-(无效)视图卸载{
[超级视频下载];
//释放主视图的所有保留子视图。
//例如,self.myOutlet=nil;
}
-(无效)解除锁定{
[super dealoc];
}
@结束
此视图不会显示在设备上,而是显示在模拟器上。设计也在xib文件中完成。在实例化视图时,我需要使用initWithNibName。之后开始工作请发布相关代码,我相信帮助会比现在和/或屏幕截图来得更快。您是自己强制执行模态还是使用presentModalViewController?我使用presentModalViewController