[英]Display one Image then second Image after User Preses “Start” on iPhone
我正在嘗試顯示兩個圖像,一個緊接另一個。 用戶按下“開始”后。 第一張圖像將顯示3秒鍾,然后第二張圖像將立即顯示。 每個圖像設置為暫停3秒。 它適用於(3G 4.2.1)在任何一個圖像都被注釋掉時在模擬器上運行的(3G 4.2.1)模擬器,但是在編碼如下時掛在第一個圖像上:
//this method gets called when the start button is pressed
-(IBAction) start {
[self.navigationController pushViewController:self.**halfSplashController** animated:YES];
[self.navigationController pushViewController:self.**halfSplash2Controller** animated:YES];
}
我是否需要在兩者之間插入命令,還是應該顯示第一個圖像,然后按我的設想繼續顯示第二個圖像?
我認為您應該使用NSTimer延遲3秒。 嘗試以下代碼
-(IBAction) start
{
[self.navigationController pushViewController:self.**halfSplashController** animated:YES];
[NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(theActionMethod) userInfo:nil repeats:NO];
[currentTimer fire];
}
- (void)theActionMethod
{
[self.navigationController pushViewController:self.**halfSplash2Controller** animated:YES];
}
它會在3秒鍾后更改圖像。如果要重復更改圖像,則在NSTimer初始化中將更改重復為YES。還要更改ActionMethod()函數中的代碼。
您也可以使用[self performSelector:afterDelay]方法,它應該可以按照您想要的方式工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.