[英]dismissing UINavigationController in iOS 5
我的問題似乎有點不可思議,我有一個自定義UITarBar
其管理幾個UINavigationController
s的一個UIViewController
呈現這些NavController
S於一個模態UITabBar
按鈕touchUpInside
,所以在iOS 5中我的應用程序,因為轟然dismissModalViewControllerAnimated:
方法..如果在iOS 5 dismissViewControllerAnimated:completion:
dismiss方法更改為新方法( dismissViewControllerAnimated:completion:
,則不會解除NavController
。 以下是我如何更換控制器的一些代碼:
- (void) changeController
{
if ([self.generalViewController respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
[self.generalViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
} else {
[self.generalViewController dismissModalViewControllerAnimated:NO];
}
[self.anotherNavController.view addSubview:customTabBar];
if ([self.generalViewController respondsToSelector:@selector(presentViewController:animated:completion:)]) {
[self.generalViewController presentViewController:anotherNavController animated:NO completion:nil];
} else {
[self.generalViewController presentModalViewController:anotherNavController animated:NO];
}
一切都在AppDelegate
管理。 謝謝你的建議。
編輯:我在這篇文章中發現了一些事情:在iOS 5中崩潰的事件:和dismissViewControllerAnimated崩潰並做了他所做的事情(呈現了第一個viewControllerAnimated動畫)然后我在iOS 5檢查新的presentViewController的選擇器之前的一切都很正常模擬器但不在設備上..
我不確定你的第一行,並認為第一行應該是:
if ([self.generalViewController respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
[self.generalViewController dismissViewControllerAnimated:YES completion:nil];
你在上面的第二行中有一個無關的.presentingViewController 。 我在上面的評論中看到你有理由,但你有沒有嘗試過替代方案?
無論如何,我在遷移到iOS 5時遇到了相關問題,並且發現解決方案是簡單地發送dismiss命令:
[self dismissViewControllerAnimated:YES];
我建議你試一試。 它對我有用,當我在那里運行代碼時,它仍然在iOS 4.2中工作...
編輯:更正,這是dismissModalViewControllerAnimated我正在糾正。 但是,在那種情況下,我發現只是將消息發送給自己而不是針對視圖控制器,這就解決了無法解除視圖的問題,並且在iOS 4和5中都工作...不能傷害到你試一試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.