- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经使用代码(没有 IB 的东西)创建了一个 UItabbarcontroller 和 2 个带有 UITableViews 的 View ,我现在想在顶部添加一个导航栏,其中包括添加和编辑按钮,但是我似乎被绊倒了我的应用程序启动或仅将导航 Controller 添加到第三个选项卡。
这是我添加标签栏和切换 View 的主要代码
仅供引用 - 我正在使用 XCode4
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.mainTabBar = [[UITabBarController alloc] init];
// create the 2 views
tableViewController* vc1 = [[tableViewController alloc] init];
tableViewController2* vc2 = [[tableViewController2 alloc] init];
// put them in an array
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
// for the tab bar
mainTabBar.viewControllers = controllers;
// Add the tab bar controller's current view as a subview of the window
[self.window addSubview:self.mainTabBar.view];
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
return YES;
}
最佳答案
你想要导航 Controller 在哪里?您必须在 UITabBarController 中为您想要的每个选项卡创建一个。
您将 navigationController 与其堆栈中的第一个 View Controller 一起添加。试试这个:
// create the controllers for UITabBarController
tableViewController *vc1 = [[[TableViewController alloc] init] autorelease];
navController *nav1 = [[[UINavigationController alloc] initWithRootViewController:vc1] autorelease];
tableViewController *vc2 = [[[TableViewController alloc] init] autorelease];
navController *nav2 = [[[UINavigationController alloc] initWithRootViewController:vc2] autorelease];
// put them in an array
NSArray *controllers = [NSArray arrayWithObjects:nav1, nav2, nil];
// rest of your code
另请注意,您需要释放分配或保留的任何内容。您可以像我一样通过在初始化它们时添加 autorelease
来做到这一点,或者您可以在将它们添加到 controllers
数组后显式释放它们。
然后根据您的实现方式,在其loadView
或viewDidLoad
方法中为每个 View Controller 配置navigationItem
。
关于iphone - 以编程方式组合 UITabController 和 UINavigation Controller http ://t. co/R52RlUL UITabController 和 UINavigation Controller 以编程方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5639945/
是否可以让一个 UITabController 成为另一个 UITabBarController 的选项卡?例如,我有一个带有 6 个选项卡的 UITabController,我可以让第六个选项卡指向
我已经使用代码(没有 IB 的东西)创建了一个 UItabbarcontroller 和 2 个带有 UITableViews 的 View ,我现在想在顶部添加一个导航栏,其中包括添加和编辑按钮,但
我正处于项目的开始阶段。它是一个带有三个选项卡的 UITabbedApplication。 [0] 位置的选项卡是“位置选择器”,[1] 选项卡是位置选择器 View 中选取的位置的“查看配置文件”。
最近尝试在我的应用程序中实现工具栏,现在我正在使用内置的 uitabcontroller。 我想知道是否可以这样编辑: http://i64.tinypic.com/iwlxzo.jpg 我找不到任何
我有两个 UITabController。一个是可从嵌套在第一个 UITabController 范围内的 UIViewController(在层次结构中较低)控制的。当我更改层次结构中较低的一个的
我正在尝试找出一种向我的应用程序添加“忙碌”动画的好方法。 因为它是一个无模式的应用程序,我不希望动画太突兀,但我认为顶部栏中的动画太容易错过了。 我想在我的应用程序的 UTIabBar 中设置一个动
我有通过带有隐藏默认栏的自定义实现(简单按钮和标签)的 Storyboard创建的选项卡 Controller 。这一切都按预期工作,并且可以浏览各种 View 。但是,在我的几个 View 中,我需
我正在尝试将“创建派对”表单中的数据转移到我的第二个“查找派对”选项卡中。 这是我的主要 Storyboard的屏幕截图: 我的创建派对 Controller 的代码: import UIKit st
这听起来可能是个新手问题……但我是 iOS 开发的新手。 我已经像这样以编程方式创建了 UITabController 对象。 mTabBarController = [[UITabBarContro
我想用这样的 UI 设计一个应用程序: 在底部,我知道它是 UITabbarController。在每个选项卡中,它有许多 View Controller ,例如 BEAT、TOP、FUN... 每个
我在尝试使 UITabBarViewController 执行与 UINavigationController 执行 PushViewController 时相同的动画时遇到问题。 - (BOOL)t
当用户在 UIAlret 上单击“确定”时,我创建了一个准备 segue 函数,它将转到 BaseTabBarViewController 中的第三个选项卡 Controller ,但我有一个问题,准
我有一个 UITabController 类,在其中我为自定义 UINavigationBar 创建了一个实例,我有兴趣将其高度传递给另一个 UIViewController.下面是我的 UITabC
我仍然没有掌握下面结构的这种传输。我读了很多帖子,也看到其他人同样未回复的帖子,但没有解决方案。 我会尽力简化问题,让大家更容易理解。 该项目的结构是:带有 tab1 和 tab2 的 UITabba
在我的应用程序中,UITabBarController 有 3 个 TabBar。 TabBarController 是从 ViewController 调用的,其中有一个 bool 变量。 我想将此
我的 Storyboard 上有以下堆栈 -> Navigation Controller -> MyCoursesViewController (does a prepareForSegue to
我的应用程序可以动态更改 AppBaseController(登录后显示)。它可以是以下之一: 菜单 Controller (类型 UIViewController)、UINavigationCont
我正在关注 How To Use UIScrollView to Scroll and Zoom Content 的“使用 UIScrollView 分页”部分将 4 张图像加载到阵列中。我应该提到我
我正在创建一个应用程序,它使用带有 5 个选项卡的 UITabController 进行导航。现在,我的应用程序加载第一个选项卡作为应用程序加载时的初始 View 。 我希望能够更改这一点,以便我有一
我有一个快速的应用程序,在我的 UIViewController 上有一个按钮。在我的 StoryBoard 中,我将按钮附加到 UITabController ,现在当用户单击它时 - 他会被重定向
我是一名优秀的程序员,十分优秀!