首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PageControl页面处理

PageControl页面处理
EN

Stack Overflow用户
提问于 2012-12-10 01:58:25
回答 1查看 132关注 0票数 0

我正在尝试对我的UIScrollView使用UIPageControl。似乎我做了一些不正确的事情,因为页面总是设置为1。

这是我的ViewDidLoad:

代码语言:javascript
复制
- (void)viewDidLoad
{
    [super viewDidLoad];

    scrollView.delegate = self;

    UIImageView *imgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tutorialScreen1.png"]];
    imgView1.frame = CGRectMake(0, 0, 320, 436);
    [scrollView addSubview:imgView1];

    UIImageView *imgView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tutorialScreen2.png"]];
    imgView2.frame = CGRectMake(320, 0, 320, 436);
    [scrollView addSubview:imgView2];

    UIImageView *imgView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tutorialScreen3.png"]];
    imgView3.frame = CGRectMake(640, 0, 320, 436);
    [scrollView addSubview:imgView3];

    scrollView.contentSize = CGSizeMake(960, 436);

    pageControl = [[UIPageControl alloc] init];

    [pageControl setNumberOfPages:3];
    [pageControl setCurrentPage:0];    
}

下面是我的UIScrollView委托方法:

代码语言:javascript
复制
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollViewx{
    NSLog(@"%f",scrollView.contentOffset.x);
    NSLog(@"%f",(scrollViewx.contentOffset.x / 320));
    pageControl.currentPage = ((scrollViewx.contentOffset.x / 320));
}

下面是y .h文件:

代码语言:javascript
复制
@interface TutorialViewController : UIViewController <UIScrollViewDelegate>

@property (nonatomic,strong) IBOutlet UIScrollView *scrollView;
@property (nonatomic,strong) IBOutlet UIPageControl *pageControl;

@end

有人知道为什么它不会改变吗?当然,我确保我的UIPageControl连接到它的实例。

感谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-10 02:34:29

好的。点没有改变,因为您已经创建了一个新的UIPageControl,而不是使用您在IB中设置的那个。外卖:pageControl = [[UIPageControl alloc] init];

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

https://stackoverflow.com/questions/13790063

复制
相关文章

相似问题

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