1

enter image description here不平衡通話開始/結束的外觀轉換爲...-的UIViewController遏制

好了,與iOS 5蘋果推出視圖控制器容器(真棒!)

以上就是我的應用程序層好像。 TabBar包含NavController包含ViewController(容器),其中包含2個表視圖,由分段控制切換。

當我選擇一個表格單元格時,它會輕鬆推動新的視圖。但是,如果我按下detailViewController內的按鈕,我希望它模態地顯示MFMailComposeViewController。其中簡要介紹了自己,然後立即自行解散。錯誤日誌我得到的是:

不平衡呼叫開始/對的UITabBarController

現在終端外形的轉變,這意味着IM試圖提出一個觀點,而其他仍然顯示或運行時間循環,我試圖加入延遲來阻止這一點,但沒有任何工作。我添加了所有的代理,並正確導入了所有的庫。

我認爲這可能與我如何從原始tableview推送新視圖或如何將視圖加載到容器中有關。該項目使用Xcode的Tab Bar應用程序模板的基本代碼,只是你知道的。下面的代碼:

的ViewController /集裝箱

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    // Alloc Init View Controllers 
    menuDrinksViewController = [[MenuDrinksViewController alloc] init]; 
    menuFoodViewController = [[MenuFoodViewController alloc] init]; 

    // Create Parent/Child relationship 
    [menuFoodViewController didMoveToParentViewController:self]; 
    [self addChildViewController:menuFoodViewController]; 

    [menuDrinksViewController didMoveToParentViewController:self]; 
    [self addChildViewController:menuDrinksViewController]; 

    [appearanceClass setBackgroundImage:self.view]; 

    // segmented controller 
    segmentedControl = [[SVSegmentedControl alloc] initWithSectionTitles:[NSArray arrayWithObjects:@"    Eat    ", @"    Drink    ", nil]]; 
    [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; 
    [appearanceClass setSegmentedControl:segmentedControl]; 
    [self.view addSubview:segmentedControl]; 

    //self.view.backgroundColor = [UIColor redColor]; 

    // Add and Size subviews 
    [self.view addSubview:menuFoodViewController.view]; 
    menuFoodViewController.view.frame = CGRectMake(0, 39, 320, self.view.frame.size.height - 40 + 1); 
    menuDrinksViewController.view.frame = CGRectMake(0, 39, 320, 327 + 1); 
} 


-(IBAction)segmentAction:(id)selector 
{ 
    // it's a custom segmented control, dw bout the code. 
    if (segmentedControl.selectedIndex == 0) 
    { 
     [self.view addSubview:menuFoodViewController.view]; 
     [menuDrinksViewController.view removeFromSuperview]; 
    } 
    else if (segmentedControl.selectedIndex == 1) 
    { 
     [self.view addSubview:menuDrinksViewController.view]; 
     [menuFoodViewController.view removeFromSuperview]; 
    } 

} 

TableViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    MenuFoodDetailViewController *menuFoodDetailViewController = [[MenuFoodDetailViewController alloc] initWithNibName:nil bundle:nil]; 
    //MenuFoodDetailViewController *menuFoodDetailViewController = [[MenuFoodDetailViewController alloc] init]; 

    [self.parentViewController.navigationController pushViewController:menuFoodDetailViewController animated:YES]; 
    [tableView deselectRowAtIndexPath:indexPath animated:NO]; 
} 

ButtonPress代碼從詳細視圖控制器。

- (void)showMailComposer 
{ 
    // attempt to delay the presentModalView call, doesnt work... 
    double delayInSeconds = 0.1; 
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 
     [self.navigationController presentModalViewController:mailComposeViewController animated:YES]; 
    }); 
} 

我知道這是很多要問,但我一直在這個好幾天。 所有與視圖無關的代碼,即MFMailViewComposer工作正常,我已經在其他應用程序中測試過它。

我已經試過各種變化的推新模式的看法,即 self.parentViewController.navigationController presentModal...(ETC)

沒有什麼工作=/

回答

3

事實證明這是iOS5內的一個錯誤。在單獨的項目上重新創建代碼後,它工作。所以我將問題追溯到iOS5外觀定製協議,當我嘗試更改UINavigationBar內的字體時,它會導致MFMailComposeViewController內的錯誤和iOS6內的另一個模式視圖。我已經提交了蘋果的雷達

0

我有同樣的問題,像前兩天..

試試這個..

當你按下'detailViewController'上的按鈕時,你試圖以模態方式呈現MFMailComposeViewController,對嗎?

所以,它拋出一個異常的原因之一是,當你以模態方式顯示MFMailComposeViewController時,你正在釋放'detailViewController'。因此,MFMailComposeViewController無法返回到'detailViewController'。

檢查您是否在'detailViewController'上使用了autorelease,或者在'detailViewController'的析構函數中放置了一個斷點並對其進行調試。

相關問題