2
編程按下中的UITabBar一樣按鈕,我用下面的代碼做出的UITabBarController:在Xcode
內AppDelegate.h
:
IBOutlet UITabBarController *rootController;
...
@property (nonatomic, retain) IBOutlet UITabBarController *rootController;
內AppDelegate.m
@synthesize rootController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];
return YES;
}
現在我需要知道如何在AppDelegate內實現此方法:
- (void)SwitchToTab:(int)index{
//go to tabview 1 or 2 ...
}
你試過 [rootController setSelectedItem:[rootController.items objectAtIndex:index]]; ? – Mat