iphone - 将焦点设置为 UITabBarItem

标签 iphone objective-c ios uinavigationcontroller uitabbarcontroller

我有一个 UITabBarController里面有几个标签栏项目。第一个标签栏项目有一个名为 A 的 View 。它有一个名为 Click 的按钮.当我单击该按钮时, View 将导航到另一个 View 。 (因为这个标签有一个 UINavigationController View 会得到一个返回按钮)。

现在这个 View 将有一个按钮,当我点击它时,我应该导航到第二个 TabItem。 (意味着 UITabBarItem 应该设置焦点,并且不应该有返回按钮(如在导航 Controller 中))

笔记 :

当用户单击按钮时,我使用以下代码导航到另一个 UITabBarItem 的另一个 View 。然后第二个标签栏项目没有设置为焦点,并且还可以看到导航 Controller 的后退按钮。

SelectSiteViewController *siteViewController =
[[SelectSiteViewController alloc] initWithNibName:@"SelectSiteViewController"
                                           bundle:nil];
[self.navigationController pushViewController:siteViewController
                                     animated:YES];

希望我把我的问题说清楚了。我该如何编码?

最佳答案

据我了解,您想从导航任务中删除当前 View Controller 并选择选项卡栏 Controller 中的第二个选项卡。

UINavigationController *navigationController = self.navigationController;
[navigationController popToRootViewControllerAnimated:NO];
[navigationController.tabBarController setSelectedIndex:1];

关于iphone - 将焦点设置为 UITabBarItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8546221/

相关文章:

iphone - Cocoa:我可以按文件名排序,如何按文件扩展名排序?

ios - 在 Facebook 帖子上分享文字

ios - 如何改变UITableView的编辑风格?

ios - 应用内 facebook 授权 - 类似于 tinder

objective-c - 在 xcode 中使用 try catch block 在真实设备上显示错误吗?

javascript - 如何使用 Google map API 进行搜索?

ios - 是否可以将 iOS 7 UIViewController 转换(特别是交互)与 subview Controller 一起使用?

objective-c - 为什么我无法关闭我加载的 View Controller ?

iOS:限制数据类型 "double"的精度而不转换为 NSString

ios - 仅在 UIScrollView 内的正确位置加载可见内容