在我的基於TabBar的iPhone應用程序中,我想在實際應用程序加載之前顯示一個全屏歡迎頁面(包含一些日誌),如何從xib文件加載UIView作爲歡迎屏幕,然後從那裏我可以加載我的基於TabBar的應用程序。在TabBarController之前加載歡迎屏幕(初始屏幕)
由於提前,
在我的基於TabBar的iPhone應用程序中,我想在實際應用程序加載之前顯示一個全屏歡迎頁面(包含一些日誌),如何從xib文件加載UIView作爲歡迎屏幕,然後從那裏我可以加載我的基於TabBar的應用程序。在TabBarController之前加載歡迎屏幕(初始屏幕)
由於提前,
這樣做將是正常加載您的標籤欄的應用程序,但使用標籤欄控制器的presentModalViewController:animated:
方法來顯示在其上的圖控制器(在application:didFinishLaunching:
)正確方法:
SplashScreenController *controller = [[SplashScreenController alloc] initWithNibNamed:nil bundle:nil];
[self.tabBarController presentModalViewController:controller animated:YES];
[controller release];
我「通常會放閃屏上的‘解僱’按鈕,但你也可以做這樣的事情:
[self.tabBarController performSelector:@selector(dismissModalViewControllerAnimated:) withObject:YES afterDelay:2.0];
將在發射呈現視圖控制器和兩個秒鐘後關閉它。將YES
改爲NO
s以避免從底部向上滑動動畫。
我在的appDelegate一個子視圖添加到主窗口:
LoginViewController *loginController = [[LoginViewController alloc] initWithNibName:@"LoginViewController"
bundle: nil];
[window addSubview: [loginController view]];
然後在LoginViewController,當我準備好解僱的視圖(顯示你的tabController說)我做的:
UIView *currentView = self.view;
UIView *theWindow = [currentView superview];
[currentView removeFromSuperview];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
海,感謝您的快速響應,我嘗試了代碼,它的工作,但底部有一個小的差距(我可以看到在後臺的標籤欄),其幾乎在頂部的狀態欄的大小。我認爲該觀點並未加載正確的來源。你有什麼想法爲什麼如此? – 2010-01-08 17:22:01
嗯..我不知道 - 你的彈簧/撐杆套件上有什麼東西可以讓視圖稍微變小一些? – 2010-01-08 19:48:04
在我的標籤欄應用程序之一,我顯示啓動畫面像這樣:
在我的應用程序委託對象,我開始在didFinishLaunchingWithOptions顯示它
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
splashScreenVC = [[SplashScreenViewController alloc] initWithNibName:@"SplashScreenView" bundle:nil];
[window addSubview:splashScreenVC.view];
[window makeKeyAndVisible];
//set delay before showing new screen
[NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(onSlashScreenExpired:) userInfo:nil repeats:NO];
return YES;
}
的onSlashScreenExpired方法是這樣的:
- (void)onSlashScreenExpired:(id)userInfo{
[splashScreenVC.view removeFromSuperview];
[splashScreenVC release];
// At this point, create the tab bar controller and display it
}
我相當肯定我鵝卵石這一起從SO另一個問題,但我找不到它。
海,感謝您的快速響應,我嘗試了代碼,它的工作,但底部有一個小的差距(我可以看到背景中的標籤欄),它幾乎在頂部狀態欄的大小。我認爲該觀點並未加載正確的來源。你有什麼想法爲什麼如此? – 2010-01-08 17:21:13
噢,我認爲這也發生在我身上。我試圖記住我做了什麼......在你的控制器中,你是否已經將它設置爲320x480,並將狀態欄,頂部欄和底部欄全部設置爲無? – Dana 2010-01-08 18:08:44
尺寸的視圖是320x460和狀態欄是 – 2010-01-11 05:43:51
的UI準則說,你不應該有一個啓動畫面 - 你應該呈現視圖,用戶將看到當應用程序加載,沒有任何數據在它的虛擬版本:
看到Apple iPhone UI Guidelines on Launch Images的細節 - 這裏是一個摘錄:
爲了提高用戶的在 啓動應用程序的經驗,你應該提供 發射圖像。啓動圖像看起來 與您的 應用程序顯示的第一個屏幕非常相似。當 用戶點擊 主屏幕上的應用程序圖標時,iPhone OS 立即顯示此圖像。只要準備好 ,您的應用程序就會顯示其 第一個屏幕,替換啓動 佔位符圖像。
重要的是要強調, 提供啓動圖像的原因是爲了提高用戶體驗 ;它不是一個 機會提供:
- 「應用入行經歷,」 如閃屏
- 一個關於 窗口
- 品牌元素,除非他們 是一個靜態部分的 應用程序的第一個屏幕
第二!不要使用啓動畫面,他們會被iPhone評論者所詬病。 – 2010-01-08 20:29:34
這是hogwash,IMO(蘋果的推理,就是這樣)。他們說「......發佈圖像是爲了改善用戶體驗......」與盯着等待數據加載的空表格相比,有什麼更糟糕的用戶體驗?關於「擱置時間似乎比實際擱置時間長3倍」的舊格言也適用於此:我不會注意到等待的時間,如果它不那麼明顯,我就在那張空桌子上等待填寫我的數據。我寧願在後臺發生,而開發人員的徽標淡入淡出(或某物)。給我看看。 – Andy 2010-05-11 14:16:27
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
splashView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"image01.png"]];
splashView.frame=CGRectMake(0,21,320,460);
[self.window makeKeyAndVisible];
[self.window addSubview:splashView];
[self performSelector:@selector(splashremove) withObject:nil afterDelay:10.5];
[self performSelector:@selector(sixthimage) withObject:nil afterDelay:9.0];
[self performSelector:@selector(fifthimage) withObject:nil afterDelay:7.5];
[self performSelector:@selector(fourthimage) withObject:nil afterDelay:6.0];
[self performSelector:@selector(thirdimage) withObject:nil afterDelay:4.5];
[self performSelector:@selector(secondimage) withObject:nil afterDelay:3.0];
[self performSelector:@selector(firstimage) withObject:nil afterDelay:1.5];
return YES;
}
-(void)firstimage
{
NSLog(@"Inside first image");
splashView.image=[UIImage imageNamed:@"image01.png"];
}
-(void)secondimage
{
NSLog(@"Inside second image");
splashView.image=[UIImage imageNamed:@"image02.png"];
}
-(void)thirdimage
{
NSLog(@"Inside third image");
splashView.image=[UIImage imageNamed:@"image03.png"];
}
-(void)fourthimage
{
NSLog(@"Inside fourth image");
splashView.image=[UIImage imageNamed:@"image04.png"];
}
-(void)fifthimage
{
NSLog(@"Inside fifth image");
splashView.image=[UIImage imageNamed:@"image05.png"];
}
-(void)sixthimage
{
NSLog(@"Inside sixth image");
splashView.image=[UIImage imageNamed:@"image06.png"];
}
-(void)splashremove
{
NSLog(@"Inside splashremove image");
[splashView removeFromSuperview];
[splashView release];
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
}
似乎是一個很好的答案。我知道現在的模式視圖控制器真的是最好的,但如果你想保持簡單,這是一樣的好。但有一個問題,你不能在應用程序委託中獲得輪換事件,所以你不能將它用於帶有自動旋轉的應用程序。 – George 2012-04-12 11:27:19
您好,我試圖和它的加載視圖 [窗口addSubview:tabBar.view]; [window makeKeyAndVisible]; [self.tabBar presentModalViewController:controller animated:NO]; 我把一個按鈕,在閃屏以關閉和我用於關閉視圖的代碼是 的UIView * currentView = self.view; [currentView removeFromSuperview]; 它將關閉啓動畫面,但不顯示TabBar。你能幫我解決這個問題嗎? – 2010-01-08 17:47:26
你想要做的就是調用'[self.parentViewController dismissModalViewControllerAnimated:YES]'(或'NO')。 – 2010-01-08 19:25:41
太感謝你了...... – 2010-01-11 06:26:24