使用视图控制器作为模态视图控制器和选项卡栏视图控制器
我有一个类似于 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。难道不可能吗?
I have a view controller alike contacts in iPhone. The code is something like this,
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;
The RemittanceFriendsVC is UITableViewController, clicking on a cell takes to details view. I have 'modal' variable set in the ViewController (VC)to know if its loaded as modal or not. Since its part of a tab bar item, (non modal view) it works fine. But when I am loading it as modal VC, when I click on a table cell, I want to dismissmodalview, but it did not dismiss the modal view.
In the friendVC this is not working,
-(void) didPressCancelButton {
[self.navigationController dismissModalViewControllerAnimated:YES];
}
What I wanted to do is, use the same VC as a tab bar item and sometime as a modal VC. Isn't it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,应该是这个问题
,
然后就可以正常工作了。
okay, it was the problem with the
it should be,
Then it works fine.