2011-03-07 5 views
0

내 iPhone 응용 프로그램에서 모달보기를 사용하고 있습니다. 문제는 뷰가 시뮬레이터에서 작동하지만 모달 뷰 대신 장치에 설치할 때 흰색 빈 화면이 표시된다는 것입니다. 누구든지 전에이 문제가 발생 했습니까? 어떻게 해결할 수 있을까요? 다음은 코드입니다. 모달보기가 장치에 표시되지 않습니다.

#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 

이보기

장치에 표시하지만, 시뮬레이터에 도시되지 않는다. 또한 설계는 xib 파일로 수행됩니다.

+0

관련 코드를 게시하면 도움이 될 것입니다. 지금보다 빨리 도움을 받으실 수 있습니다. – Bourne

+0

그리고 가능한 경우 스크린 샷을 참조하십시오. 당신은 자신의 양식을 적용하거나 presentModalViewController와 같은 것을 사용하고 있습니까? – Ternary

+0

현재 사용중인 modalViewController –

답변

0

내 견해를 인스턴스화하는 동안 initWithNibName을 사용해야합니다. 그 이후에 작업을 시작했습니다