本文介紹了如何使用計(jì)時(shí)器自動(dòng)滾動(dòng) UIScrollView?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我有一個(gè) UIScrollView
來(lái)顯示圖像.我需要一個(gè)計(jì)時(shí)器,每 5 秒后一個(gè)接一個(gè)地顯示圖像.如何使用定時(shí)器啟動(dòng)UIScrollView
事件5秒后移動(dòng)到下一張圖片?
I have a UIScrollView
to show images. I need a timer to show the images one after another, after every 5 seconds. How to initiate UIScrollView
event to move to the next image after 5 seconds using the timer?
推薦答案
將變量 int h 添加到您的界面,并將 yourScrollView 作為屬性.然后:
Add the variable int h to your interface, and yourScrollView as a property. Then:
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
- (void) onTimer {
// Updates the variable h, adding 100 (put your own value here!)
h += 100;
//This makes the scrollView scroll to the desired position
yourScrollView.contentOffset = CGPointMake(0, h);
}
這篇關(guān)于如何使用計(jì)時(shí)器自動(dòng)滾動(dòng) UIScrollView?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!