0
我是iOS开发新手。我有一个启动画面,并希望用初始视图替换它,我的意思是一个图像和两个按钮。我如何设置初始视图?我使用的Xcode 4的iOS 4,这里是我的代码...iOS初始屏幕按钮
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIView *backgroundView = [[UIView alloc] initWithFrame: window.frame];
backgroundView.backgroundColor = [UIColor lightGrayColor];
[window addSubview:backgroundView];
[backgroundView release];
// Override point for customization after application launch.
DataController *appController = [DataController sharedObject];
tabController = [[UITabBarController alloc] init];
HomeViewController *hemView = [[HomeViewController alloc] init];
[hemView setTitle:@"Hem"];
hemView.tabBarItem.image = [UIImage imageNamed:@"icon_home.png"];
UINavigationController *homeNavigationController = [[UINavigationController alloc] initWithRootViewController:hemView];
[homeNavigationController.navigationBar setTintColor:[UIColor colorWithRed:(0.96) green:(0.96) blue:(0.96) alpha:0.0]];
[hemView release];
SearchViewController *sdkView = [[SearchViewController alloc] init];
[sdkView setTitle:@"Search"];
sdkView.tabBarItem.image = [UIImage imageNamed:@"icon_search.png"];
UINavigationController *sdkNavigationController = [[UINavigationController alloc] initWithRootViewController:sdkView];
[sdkNavigationController.navigationBar setTintColor:[UIColor colorWithRed:(0.96) green:(0.96) blue:(0.96) alpha:0.0]];
[sdkView release];
NSArray * arrayOfControllers = [[NSArray alloc] initWithObjects:homeNavigationController, sdkNavigationController, nil];
tabController.viewControllers = arrayOfControllers;
SplashScreenViewController *controller = [[SplashScreenViewController alloc] init];
[tabController presentModalViewController:controller animated:YES];
[controller release];
[self.window makeKeyAndVisible];
[window addSubview:tabController.view];
[homeNavigationController release];
[sdkNavigationController release];
[appController release];
return YES;
}
但这码不显示启动画面,它需要我直接到HomeViewController,请帮助。
最简单的方法是使用Xcode的集成Interface Builder。如果您是Xcode的新手,请遵循Apple的开发者教程。 – BoltClock 2011-06-08 10:27:49