- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个包含三个选项卡的基于选项卡栏的应用程序。现在,当设备从纵向旋转到横向时,它应该加载不同的 UIViewController 并且当应用程序模式从横向更改回纵向模式时,应该再次显示标签栏 Controller 。如何做到这一点?
最佳答案
我猜你可以用下面的方法解决这个问题。由于您有两个位于同一层级的不同 ViewController,因此有一个 ViewController 是有意义的,它管理这两个 ViewController 并根据方向显示相应的 ViewController。
肖像
MyRootViewController
(UIViewController
子类)
MyTabBarViewController
(UITabBarViewController
子类)风景
MyRootViewController
(UIViewController
子类)
MyPortraitViewController
(UIViewController
子类)现在您的 MyRootViewController
类会检测到任何旋转(请参阅 UIViewController
文档)并将其 View 更改为您的两个 ViewController 之一:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
// Set the view to the corresponding ViewController (Assuming they were already initialized)
if(UIInterfaceOrientationIsPortrait(toInterfaceOrientation)){
self.view = self.myTabBarViewController.view;
} else {
self.view = self.myPortraitViewController.view;
}
}
您还应该确保在您的应用程序启动/重新激活时显示正确的 ViewController。为此,您可以在 MyRootViewController 类中使用以下方法:
- (void)viewWillAppear:(BOOL)animated;
希望对你有帮助
关于iphone - 如何从 UIViewController 调用 tabbarviewcontroller?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8558554/
我有一个 View Controller 和 tabbarviewcontroller。我有 viewcontroller 和 tabbarviewcontroller 之间的连接。示例:如果我单击
这里有两个自定义的UITabBarViewController演示 BrowserTabViewDemo AKTabBarController 我总是使用 UITabBarController 来制作
我有一个实现了 UITabbarViewController 的 View Controller ,我想隐藏它标签栏并自己覆盖它, self.tabBar.hidden = YES; 选项卡栏消失了,
我的项目中有一个带有三个 Tap 的 TapBarViewController。 现在,当应用程序启动时,我尝试在 TapBar ViewController 前面放置一个普通的 FirstViewC
我可以在 TabBarViewController 类中创建一些 @property 吗?我将在 subViewControllers 中调用它,并在 subViewCintrollers 的方法 v
我的 TabBarVC 是我的应用程序的核心。我有 3 个 View Controller 。每个 View Controller 都“嵌入”在导航 Controller 中。 TabBarVC ->
我有一个基于 UITabBarController 的应用程序,我想将数据从一个 View 传递到另一个 View 。我在 Storyboard 中执行此操作,我只是在将其引入主应用程序之前进行一些测
在stackoverflow中阅读了相当多的问题后,我目前仍然找不到答案。 我无法将 ManagedObjectContext 从 appdelegate 传递到我的 tabbarcontroller
我正在创建一个 iOS 应用程序。当我单击“登录”按钮时,服务器通过将 JSON 发送回应用程序进行响应。我知道信息正在被发回,因为我可以从 LoginVC 打印信息。 登录成功后,我想将服务器响应“
我正在尝试使用导航 Controller 中的导航栏,同时使用 UITabBarController 中的选项卡栏。如果我将导航 Controller 的根 Controller 设置为我的选项卡栏
我正在使用这个库 https://github.com/fpt-software/Material-Controls-For-iOS/在我的 iOS 应用程序中。具体来说,我正在使用 MDTabBar
我已经寻找解决方案 6 个小时了,但没有找到适合我情况的解决方案。我的 Storyboard遵循以下流程: TabBarViewController -> NavigationController -
我的 tvOS 应用程序没有或不需要正确的登录屏幕,但我确实有一个在首次启动时从 AppDelegate 调用的检查。我遇到的问题是,当我的后端发生 checkUser 时,整个应用程序变成了银色。我
我有一个包含三个选项卡的基于选项卡栏的应用程序。现在,当设备从纵向旋转到横向时,它应该加载不同的 UIViewController 并且当应用程序模式从横向更改回纵向模式时,应该再次显示标签栏 Con
我是初学者 iOS 应用程序开发人员。我正在做 Web 服务应用程序并依赖于 API。我的应用程序是在选项卡栏 viewcontrller 应用程序上创建的。我在登录详细信息中使用了第一个选项卡,在注
这是我的应用程序的层次结构 有一个带有 4 个选项卡的 TabBarViewCOnyroller 每个选项卡显示一个 TableListViewOCnroller 当用户在 TableListView
我想在从UITabbarViewController中选择选项卡的ant时删除iPhone X(10)中的蓝色突出显示 最佳答案 您可以通过使用属性tintColor来自定义它仅对选项卡栏的项目指定颜
我知道我可以做到这一点 [self.navigationController pushViewController:self.someUITabBarController animated:YES]
我正在从一个 View Controller 切换到一个 tabbarcontroller,我想传递数据。我想将“sendAuthor”传递给 tabbarcontroller 的第一个 View C
我正在尝试呈现 NavigationController 并在完成 block 中选择第二个选项卡。我的代码是: let chatViewController = UITabBarController
我是一名优秀的程序员,十分优秀!