ios - PageView 幻灯片
<p><p>我是新来的,需要一些帮助,我正在为 ipad 制作一个 ios 应用程序,并希望能够在页面 View 中使用自定义和/或库存转换为页面转换设置动画。</p>
<p>在各个页面 (PageView) 中设置全屏照片的正确方法是什么?类似于苹果照片应用程序。我希望能够设置一个基本的幻灯片并通过它们进行过渡。 </p>
<p>感谢所有帮助。</p>
<p>谢谢</p>
<p>编辑:哇,这些响应速度很快,是否也可以有自定义动画?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你可以这样创建:-</p>
<pre><code>- (void)viewDidLoad {
;
UIScrollView *scr=[ initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scr.tag = 1;
scr.autoresizingMask=UIViewAutoresizingNone;
;
;
UIPageControl *pgCtr = [ initWithFrame:CGRectMake(0, 264, 480, 36)];
;
pgCtr.numberOfPages=10;
pgCtr.autoresizingMask=UIViewAutoresizingNone;
;
}
- (void)setupScrollView:(UIScrollView*)scrMain {
// we have 10 images here.
// we will add all images into a scrollView &amp; set the appropriate size.
for (int i=1; i&lt;=10; i++) {
// create image
UIImage *image = ];
// create imageView
UIImageView *imgV = [ initWithFrame:CGRectMake((i-1)*scrMain.frame.size.width, 0, scrMain.frame.size.width, scrMain.frame.size.height)];
// set scale to fill
imgV.contentMode=UIViewContentModeScaleToFill;
// set image
;
// apply tag to access in future
imgV.tag=i+1;
// add to scrollView
;
}
// set the content size to 10 image width
;
// enable timer after each 2 seconds for scrolling.
;
}
- (void)scrollingTimer {
// access the scroll view with the tag
UIScrollView *scrMain = (UIScrollView*) ;
// same way, access pagecontroll access
UIPageControl *pgCtr = (UIPageControl*) ;
// get the current offset ( which page is being displayed )
CGFloat contentOffset = scrMain.contentOffset.x;
// calculate next page to display
int nextPage = (int)(contentOffset/scrMain.frame.size.width) + 1 ;
// if page is not 10, display it
if( nextPage!=10 ){
;
pgCtr.currentPage=nextPage;
// else start sliding form 1 :)
} else {
;
pgCtr.currentPage=0;
}
}
</code></pre>
<p>你可以使用:-</p>
<p> <a href="https://github.com/rs/SDWebImage" rel="noreferrer noopener nofollow">SDWebimage</a> </p>
<p> <a href="https://github.com/AFNetworking/AFNetworking" rel="noreferrer noopener nofollow">AFNetworking</a> </p>
<p> <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Reference/NSCache_Class/Reference/Reference.html" rel="noreferrer noopener nofollow">NSCache</a>和 <a href="https://stackoverflow.com/questions/12703297/uitableview-with-images-scrolls-very-slowly" rel="noreferrer noopener nofollow">use of NSCache</a> </p>
<p>用于图片缓存和异步加载图片</p>
<p><strong>更新:-</strong></p>
<p>这里的 Bellow 是一些库,它可以做一些类似照片库幻灯片放映的事情,请检查这个,如果你愿意,然后通过阅读如何实现将其用于你的项目。</p>
<p> <a href="https://github.com/mwaterfall/MWPhotoBrowser" rel="noreferrer noopener nofollow">MWPhotoBrowser for iOS</a> </p>
<p> <a href="https://github.com/enormego/PhotoViewer" rel="noreferrer noopener nofollow">EGOPhotoViewer for iOS</a> </p>
<p> <a href="https://github.com/ChrisXu1221/CXPhotoBrowser" rel="noreferrer noopener nofollow">CXPhotoBrowser for iOS</a> </p>
<p> <a href="https://github.com/gdavis/FGallery-iPhone" rel="noreferrer noopener nofollow">FGallery for iOS</a> </p>
<p> <a href="https://www.cocoacontrols.com/controls/nimbus" rel="noreferrer noopener nofollow">Nimbus for iOS</a> </p>
<p> <a href="https://github.com/exalted/PTImageAlbumViewController" rel="noreferrer noopener nofollow">PTImageAlbumViewController for iOS</a> </p></p>
<p style="font-size: 20px;">关于ios - PageView 幻灯片,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/18798435/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/18798435/
</a>
</p>
页:
[1]