0

我想知道当用户查看一个故事/内容的视图时如何执行左右滑动等操作,然后它返回或前进到下一个内容,共 x 页。

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

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

4

2 回答 2

1

这个 ui 元素被称为UIPageControl

于 2012-08-24T01:29:32.033 回答
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];

 }
于 2012-08-24T02:07:15.653 回答