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