Xcode滑动以在内容页面之间导航

时间:2012-08-24 01:23:54

标签: objective-c xcode

我想知道如何在用户查看一个故事/内容的视图时左/右滑动,然后返回或转发到y页的x的下一个内容。< / p>

类似于CNN iOS应用程序的功能,带有一排小圆圈,表示用户现在正在查看的位置。

来自Xcode的滑动手势识别器是实现它的主要因素吗?

2 个答案:

答案 0 :(得分:1)

此ui元素称为UIPageControl

答案 1 :(得分:0)

-(void)scrollView
 {

scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,0,320,460)];
scrollView.backgroundColor = [UIColor clearColor];

 scrollView.pagingEnabled = YES;
 [scrollView setScrollsToTop:YES];

 scrollView.showsVerticalScrollIndicator=NO;
scrollView.showsHorizontalScrollIndicator=NO;

 scrollView.contentSize = CGSizeMake(320*totalPages,460);
 scrollView.delegate = self;

 [self.view addSubview:scrollView];

}

-(void)makePages
{

 for (int i=0; i<totalPages; i++) 
 {
    containerView = [[UIView alloc]initWithFrame:CGRectMake(320*i,0,320,460)];
    containerView.backgroundColor = [UIColor clearColor];
    containerView.tag = i;

    if(i%2 == 0)
        containerView.backGroundColor = [UIColor blueColor];
     else
        containerView.backGroundColor = [UIColor blueColor];

    [scrollView addSubview:containerView];

 }

[scrollView scrollRectToVisible:CGRectMake(0,0,320,460) animated:YES];

 }