iphone - 图像幻灯片
<p><p>我正在开发一个简单幻灯片的应用程序。</p>
<p>描述:在应用程序中,我将 5 张图像存储在一个数组中。目前我将图像显示到 ScrollView 中,但我想显示存储在数组中的图像的幻灯片。我怎样才能做到这一点 ?有教程吗?</p>
<p>问候</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我建议使用 NSTimer,这是一些基本代码。但是,必须根据您希望如何处理边缘情况来计算“页”数,例如:幻灯片放映中的最后一张图片。</p>
<p>看看<a href="http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html" rel="noreferrer noopener nofollow">Apple's example app PageControl</a> ,它展示了如何在分页 ScrollView 中有效处理内存的好方法。</p>
<pre><code>self.slideTimer = [NSTimer scheduledTimerWithTimeInterval:3.0
target:self
selector:@selector(slide)
userInfo:nil
repeats:YES];
...
- (void)slide
{
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * nextImagePageNumber;
frame.origin.y = 0;
;
}
</code></pre>
<p><strong> <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html" rel="noreferrer noopener nofollow">NSTimer</a> </strong></p>
<blockquote>
<p>You use the NSTimer class to create
timer objects or, more simply, timers.
A timer waits until a certain time
interval has elapsed and then fires,
sending a specified message to a
target object. For example, you could
create an NSTimer object that sends a
message to a window, telling it to
update itself after a certain time
interval.</p>
</blockquote></p>
<p style="font-size: 20px;">关于iphone - 图像幻灯片,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/5963687/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/5963687/
</a>
</p>
页:
[1]