首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PageView幻灯片

PageView幻灯片
EN

Stack Overflow用户
提问于 2013-09-14 04:53:58
回答 1查看 1.6K关注 0票数 2

我是新来的,可能需要一些帮助,我正在为ipad制作一个ios应用程序,我希望能够用自定义和/或股票转换动画化页面视图中的页面转换。

通过不同的页面(PageView)动画的正确方法是什么?每个页面中都有全屏照片?类似苹果照片应用程序。我希望能够建立一个基本幻灯片,并通过他们过渡。

所有的帮助都是感激的。

谢谢

编辑:哇,这些反应是快速的,它也有可能有定制动画?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-14 04:55:50

你可以这样创作:-

代码语言:javascript
复制
- (void)viewDidLoad {
    [super viewDidLoad];
    UIScrollView *scr=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    scr.tag = 1;
    scr.autoresizingMask=UIViewAutoresizingNone;
    [self.view addSubview:scr];
    [self setupScrollView:scr];
    UIPageControl *pgCtr = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 264, 480, 36)];
    [pgCtr setTag:12];
    pgCtr.numberOfPages=10;
    pgCtr.autoresizingMask=UIViewAutoresizingNone;
    [self.view addSubview:pgCtr];
}

- (void)setupScrollView:(UIScrollView*)scrMain {
    // we have 10 images here.
    // we will add all images into a scrollView & set the appropriate size.

    for (int i=1; i<=10; i++) {
        // create image
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"sti%02i.jpeg",i]];
        // create imageView
        UIImageView *imgV = [[UIImageView alloc] 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
        [imgV setImage:image];
        // apply tag to access in future
        imgV.tag=i+1;
        // add to scrollView
        [scrMain addSubview:imgV];
    }
    // set the content size to 10 image width
    [scrMain setContentSize:CGSizeMake(scrMain.frame.size.width*10, scrMain.frame.size.height)];
    // enable timer after each 2 seconds for scrolling.
    [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(scrollingTimer) userInfo:nil repeats:YES];
}

- (void)scrollingTimer {
    // access the scroll view with the tag
    UIScrollView *scrMain = (UIScrollView*) [self.view viewWithTag:1];
    // same way, access pagecontroll access
    UIPageControl *pgCtr = (UIPageControl*) [self.view viewWithTag:12];
    // 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 )  {
        [scrMain scrollRectToVisible:CGRectMake(nextPage*scrMain.frame.size.width, 0, scrMain.frame.size.width, scrMain.frame.size.height) animated:YES];
        pgCtr.currentPage=nextPage;
    // else start sliding form 1 :)
    } else {
        [scrMain scrollRectToVisible:CGRectMake(0, 0, scrMain.frame.size.width, scrMain.frame.size.height) animated:YES];
        pgCtr.currentPage=0;
    }
}

你可以使用:-

SDWebimage

AFNetworking

NSCacheNSCache的使用

用于图像缓存和异步加载映像。

更新:-

这里贝娄是一些图书馆,做一些像图片库,幻灯片放映,检查这个,如果你想,然后使用在你的项目,阅读如何实现。

MWPhotoBrowser for iOS

EGOPhotoViewer for iOS

CXPhotoBrowser for iOS

FGallery for iOS

用于iOS的Nimbus

PTImageAlbumViewController for iOS

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18798435

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档