本文介紹了如何使用計時器自動滾動 UIScrollView?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個 UIScrollView
來顯示圖像.我需要一個計時器,每 5 秒后一個接一個地顯示圖像.如何使用定時器啟動UIScrollView
事件5秒后移動到下一張圖片?
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);
}
這篇關于如何使用計時器自動滾動 UIScrollView?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!