2012-07-09 84 views
0

我在特定幀CGRectMake(40,50,400,500)中顯示aNavController作爲modalViewController。哪個工作正常。現在我有一個自己的按鈕(viewcontroller上顯示modalViewController),按下那個按鈕,我需要在一個NavController上顯示一些消息。但問題是當我呈現一個modalViewController。整個屏幕區域變暗/禁用。所以,無法觸摸/點擊自己的按鈕。ModalViewController沒有調光/禁用當前視圖控制器

這是我的代碼來呈現視圖控制器。我想,我在這裏錯過了一些東西。請幫忙。提前致謝。

aNavController.modalPresentationStyle = UIModalPresentationFormSheet; 
anavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
[self presentModalViewController:aNavController animated:YES]; 
aNavController.view.superview.frame = CGRectMake(40,50, 400, 500); 

回答

0

最後,我能夠解決與UIModalPresentationFormSheet工作方式相同的解決方法。

我添加了aNavController作爲[[UIApplication sharedApplication] keyWindow]的子視圖,它解決了我所有的問題。

謝謝大家的意見。

1

presentModalViewController創建一個模態對話框。當模態視圖控制器啓動時,用戶不能在父視圖上做任何事情,直到模態視圖被解除。

+0

是的你是對的,用戶不能在父視圖上做任何事情,直到模型視圖被解除。我知道那件事,在這裏我想要一個解決方法。無論如何,感謝您的評論。 – 2012-07-27 05:08:54

0

問題是你正在實例化一個UIAlertViewpresentModalViewControllerUIAlertView的代理方法clickedButtonAtIndex中調用你的模態視圖的同時。

像這樣:

- (IBAction)clickedMyButton:(id)sender 
{ 
    UIAlertView *alertView = [[UIAlertView alloc] 
       initWithTitle: @"Title" 
       message: @"Message" 
       delegate:self 
       cancelButtonTitle:@"Close Button" 
       otherButtonTitles:@"Modal Button", @"Some Other Button", nil]; 
    [alertView show]; 
} 



- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if (buttonIndex == 0) { 
     NSLog(@"User Selected Cancel"); 
    } 
    else if (buttonIndex == 1) { 
     NSLog(@"Modal Button Clicked"); 
     aNavController.modalPresentationStyle = UIModalPresentationFormSheet; 
     anavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
     [self presentModalViewController:aNavController animated:YES]; 
     aNavController.view.superview.frame = CGRectMake(40,50, 400, 500); 
    }else { 
     NSLog(@"Some Other Button Clicked"); 
    } 
} 

或者,如果你想爲你的UIAlertView出現在您的導航控制器的頂部,忽略上面的,只是等待打電話給你的警告,直到導航控制器- (void)viewDidAppear:(BOOL)animated方法。除非絕對必要,否則我建議你改變你的框架以保持在屏幕的邊界內。例如:CGRectMake(40, 50, 320, 480);

相關問題