我在此代码行中收到一条错误,指出“预期标识符”
UINavigationController *navController1 = [[[UINavigationController alloc] initWithRootViewController:viewController4]];
此代码放置在应用程序Delegate中,如下所示
#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ParkTable.h"
#import "TableTest.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
@synthesize ParkTableDel = _tableViewController;
@synthesize navController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
UITableViewController *viewController3 = [[ParkTable alloc] initWithNibName:@"ParkTable" bundle:nil];
UITableViewController *viewController4 = [[TableTest alloc] initWithNibName:@"TableTest" bundle:nil];
UINavigationController *navController1 = [[[UINavigationController alloc] initWithRootViewController:viewController4]];
self.tabBarController = [[UITabBarController alloc] init];
self.ParkTableDel = [[UITableViewController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, viewController4, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
// [...] Boilerplate code removed.
@end
我想知道我必须改变什么以使其正确。
答案 0 :(得分:16)
这可能是额外的括号吗? []
答案 1 :(得分:1)
正如卢克所指出的,你有一套额外的括号。
要纠正黑屏,请尝试..
[self.window addSubview: self.tabBarController.view]
而不是..
self.window.rootViewController = self.tabBarController;
答案 2 :(得分:0)
有同样的问题。它可能是你的代码行附近的[]的额外集合。