Iphone 我想实现TabBarController并添加导航控制器视图,但没有成功
我知道如何通过Interface Builder添加带有两个TabBar按钮的TabBar。我将每个按钮链接到导航控制器 现在我想学习如何以编程的方式做每件事。现在我可以在模拟器中看到一个选项卡栏,但上面没有按钮。谁能帮我一下吗。谢谢 这是TabBarAppDelegate.hIphone 我想实现TabBarController并添加导航控制器视图,但没有成功,iphone,objective-c,uinavigationcontroller,uitabbarcontroller,tabbar,Iphone,Objective C,Uinavigationcontroller,Uitabbarcontroller,Tabbar,我知道如何通过Interface Builder添加带有两个TabBar按钮的TabBar。我将每个按钮链接到导航控制器 现在我想学习如何以编程的方式做每件事。现在我可以在模拟器中看到一个选项卡栏,但上面没有按钮。谁能帮我一下吗。谢谢 这是TabBarAppDelegate.h #import <UIKit/UIKit.h> @interface TabBarAppDelegate : NSObject <UIApplicationDelegate> { UIW
#import <UIKit/UIKit.h>
@interface TabBarAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
UITabBarController *tabBarController;
IBOutlet UINavigationController *navigationController1;
IBOutlet UINavigationController *navigationController2;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UITabBarController *tabBarController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController1;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController2;
@end
看起来您没有初始化导航视图控制器。看看这是否可行: TabBarAppDelegate.h
- 删除属性navigationController1和navigationController2
- 替换
[self.navigationController1 pushViewController:firstViewController animated:NO];
[self.navigationController2 pushViewController:secondViewController animated:NO];
- 替换
[self.navigationController1 pushViewController:firstViewController animated:NO];
[self.navigationController2 pushViewController:secondViewController animated:NO];
- 将navigationController1和navigationController2添加到tabBarController后,释放它们
UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:secondViewController];