我正在处理UINavigationControllers我的应用程序,所有这些都由UITabBarController. 一切正常,直到我的控制器进入自动生成的“更多”选项卡。
我在这个简单的例子中重现了这个问题。难道我做错了什么?我想不通。
谢谢你的帮助。
#import <UIKit/UIKit.h>
@interface testAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>
{
UIWindow *窗口;
UITabBarController *tabBarController;
}
@property (nonatomic, 保留) IBOutlet UIWindow *window;
@property(非原子,保留)IBOutlet UITabBarController *tabBarController;
@结尾
@implementation testAppDelegate
@synthesize 窗口,tabBarController;
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
UINavigationController *ctrl1 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
ctrl1.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:1] autorelease];
UINavigationController *ctrl2 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
ctrl2.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:2] autorelease];
UINavigationController *ctrl3 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
ctrl3.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:3] autorelease];
UINavigationController *ctrl4 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
ctrl4.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:4] autorelease];
// 这个不行
UINavigationController *ctrl5 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
ctrl5.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostRecent tag:5] autorelease];
// 这个可以工作
UIViewController *ctrl6 = [[[UIViewController alloc] initWithNibName:nil bundle: nil] autorelease];
ctrl6.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:6] autorelease];
tabBarController.viewControllers = [NSArray arrayWithObjects:ctrl1, ctrl2, ctrl3, ctrl4, ctrl5, ctrl6, nil];
[窗口添加子视图:tabBarController.view];
[窗口 makeKeyAndVisible];
}
- (void)dealloc
{
[tabBarController 发布];
[窗口释放];
[超级释放];
}
@结尾