我正在創建一個簡單的模態ViewController。我用一個按鈕創建一個筆尖,然後按下該按鈕,調用一個方法來顯示模式viewController,我在其中創建viewController和一個按鈕,像這樣。Modal viewController解僱按鈕問題
UIViewController *modalViewController = [[UIViewController alloc]initWithNibName:nil bundle:nil];
modalViewController.view.backgroundColor = [UIColor redColor];
modalViewController.;
UIButton *btnDismissViewController = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btnDismissViewController.frame = CGRectMake(60, 160, 150, 50);
[btnDismissViewController setTitle:@"DISMISS" forState:UIControlStateNormal];
[btnDismissViewController addTarget:self action:@selector(dismissViewCOntroller) forControlEvents:UIControlEventTouchUpOutside];
btnDismissViewController.backgroundColor = [UIColor grayColor];
[modalViewController.view addSubview:btnDismissViewController];
[self presentModalViewController:modalViewController animated:YES];
該視圖正常顯示,但在按下modalViewController上的按鈕後,不會調用解除modalViewController的目標方法。我肯定錯過了明顯的東西,但沒有得到什麼。任何人都可以幫忙嗎?
Thanx提前。
請向我們展示'dismissViewCOntroller'方法的定義。您定義選擇器的方式應該如下所示,使用兩個大寫字母和全部:' - (void)dismissViewCOntroller'(無發送者參數)。 – 2010-06-26 20:05:05
另外,你確定你不是故意寫'UIControlEventTouchUpInside'嗎? – 2010-06-26 20:05:48
感謝名單,奧,IWasRobbed和Macatomy ......是的,有一個錯字。我應該寫「UIControlEventTouchUpInside」,這無意中被寫成UIControlEventTouchUpOutside .. – neha 2010-06-28 06:12:34