2012-12-17 45 views
-2

cell用戶點擊後,我這樣做後的一些代碼:從定製的UITableView類dismissModalViewControllerAnimated?

[self.window.rootViewController presentModalViewController:mailer animated:YES]; 

然後當他擊中了取消按鈕或在此方法發送:

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
[[((UIViewController *)(self.superview.superclass)) presentedViewController] dismissModalViewControllerAnimated:NO]; 
} 

,但我的應用程序崩潰,走出去。

012-12-17 18:52:09.243 testapp[8293:15203] Mail cancelled: you cancelled the operation and no email message was queued 
2012-12-17 18:52:09.243 testapp[8293:15203] +[UIResponder presentedViewController]: unrecognized selector sent to class 0xbb5db0 
2012-12-17 18:52:09.244 testapp[8293:15203] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIResponder presentedViewController]: unrecognized selector sent to class 0xbb5db0' 
*** First throw call stack: 
(0x1ba6022 0x1688cd6 0x1ba7aad 0x1b0ced0 0x1b0ccb2 0x4e466 0xa99bf 0xac64f 0xa63f2 0x8d05af 0x1ba7e99 0x50f14e 0x50f0e6 0x5b5ade 0x5b5fa7 0x5b5266 0x5343c0 0x5345e6 0x51adc4 0x50e634 0x1d39ef5 0x1b7a195 0x1adeff2 0x1add8da 0x1adcd84 0x1adcc9b 0x1d387d8 0x1d3888a 0x50c626 0x370d 0x26c5 0x1) 
+0

任何錯誤或警告? – vikingosegundo

+0

建立成功。但是當運行該應用程序,並嘗試解僱崩潰 – Omarj

+0

@Mindaugas? – Omarj

回答

0

嘗試[controller dismissModalViewControllerAnimated:NO];

+0

作品像一個魅力:) thanx thanx thanx – Omarj

+0

你歡迎任何時間;) –

0

儘量簡單[self dismissViewControllerAnimated:NO completion:nil]

+0

如果你閱讀我的問題,你會知道這會給我一個錯誤。 – Omarj

+0

它是自定義tableview類,所以它會給我(沒有可見@interface爲'CustomTableView'聲明選擇器'dismissViewControllerAnimated:' – Omarj

+0

那麼這是不完全相同的[[((UIViewController *)(self.superview.superclass ))presentsViewController] dismissModalViewControllerAnimated:NO];'。嘗試激活一個異常斷點,它在崩潰時說什麼? – Levi

0

如果你想從VC駁回那麼這應該工作:

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    [self dismissModalViewControllerAnimated:NO]; 
} 
+0

你會知道這會給我一個錯誤。 – Omarj

+0

請發佈錯誤/異常當應用程序崩潰時被打印到日誌中 –

+0

它是自定義的tableview類,所以它會給我(沒有可見的@interface 'CustomTableView'聲明選擇器'dismissViewControllerAnimated:' – Omarj

0

的原因崩潰是隻有presentedViewController存在於iOS 5和更高版本中。如果你在iOS 4上運行它,它會導致你顯示的異常。

dismissModalViewController是解除用iOS 4 + 5的presentModalViewController呈現的控制器的正確方法。它仍然適用於iOS 6,但不推薦使用。你有presentViewController和dismissViewController。

相關問題