【问题标题】:Using a view controller both as modal view controller and as a tab bar view controller使用视图控制器作为模态视图控制器和标签栏视图控制器
【发布时间】:2010-10-04 11:07:33
【问题描述】:

我在 iPhone 中有一个类似于 联系人 的视图控制器。代码是这样的,

tabBarController = [[UITabBarController alloc] init];
friendsVC = [[RemittanceFriendsVC alloc] initWithNibName:@"RemittanceFriendsView" bundle:nil];
friendsVC.friendsArray = [[RemittanceModel getInstance] friends];
UINavigationController *friendsNVC = [[UINavigationController alloc] initWithRootViewController: friendsVC];
[controllers addObject:friendsNVC];
tabBarController.viewControllers = controllers;

RemittanceFriendsVC 是 UITableViewController,单击一个单元格将进入详细信息视图。我在 ViewController (VC) 中设置了“模态”变量,以了解它是否加载为模态。由于它是标签栏项目的一部分,(非模态视图)它工作正常。但是当我将它作为模态 VC 加载时,当我单击表格单元格时,我想关闭模态视图,但它并没有关闭模态视图。

在friendVC中这不起作用,

-(void) didPressCancelButton {
        [self.navigationController dismissModalViewControllerAnimated:YES];
}

我想做的是,将相同的 VC 用作选项卡栏项目,有时用作模态 VC。不可以吗?

【问题讨论】:

    标签: iphone uitabbarcontroller modalviewcontroller


    【解决方案1】:

    好的,问题出在

    [self.navigationController dismissModalViewControllerAnimated:YES];
    

    应该是,

    [self dismissModalViewControllerAnimated:YES];
    

    然后它工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-10
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      相关资源
      最近更新 更多