我剛創建了帶有側面菜單的標籤欄控制器我得到了與黑色屏幕輸出,但我不知道如何分配應用程序委託兩個視圖控制器請告訴我如何使它work.i需要特定的代碼才能使其工作。在標籤欄和側面菜單中的視圖控制器問題
//AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate,UITabBarControllerDelegate>
{
UINavigationController *navigationController;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong,nonatomic)UITabBarController *tabBarController;
//AppDelegate.m
@interface AppDelegate()<SWRevealViewControllerDelegate>
@end
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
self.tabBarController =[[UITabBarController alloc]init];
//Initialize View controller and speciality
UIViewController *viewcontroller1=[[HomeView alloc]init];
UIViewController *viewcontroller2=[[Speciality alloc]init];
UIViewController *viewcontroller3=[[Activity alloc]init];
UIViewController *viewcontroller4 =[[Notification alloc]init];
UIViewController *viewcontroller5 =[[Profile alloc]init];
self.tabBarController.viewControllers=[NSArray arrayWithObjects:viewcontroller1,viewcontroller2,viewcontroller3,viewcontroller4,viewcontroller5, nil];
self.tabBarController.tabBar.barTintColor = [UIColor colorWithRed:0.376 green:0.729 blue:0.318 alpha:1.000];
self.window.backgroundColor = [UIColor whiteColor];
HomeView *frontViewController = [[HomeView alloc] init];
RearViewController *rearViewController = [[RearViewController alloc] init];
UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearViewController];
SWRevealViewController *mainRevealController = [[SWRevealViewController alloc]
initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
mainRevealController.delegate = self;
self.viewController = mainRevealController;
self.window.backgroundColor= [UIColor whiteColor];
self.window.rootViewController =self.tabBarController;
self.window.rootViewController=self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
我在4天前問你這個問題,我忘了回答,就像我說過的那樣,但是如果你有問題,請回頭看看你有沒有問題,現在你已經有了完整的答案 – Loxx