UIPage 控件仅在第 4 页点后响应
Posted
技术标签:
【中文标题】UIPage 控件仅在第 4 页点后响应【英文标题】:UIPage Control responding only after 4th page dot 【发布时间】:2012-08-20 19:12:31 【问题描述】:这里是代码,当页面超过 5 时,点只有在点击第 4 页及以上时才会响应,而反过来,第 2 和第 3 个点是可选的
if(self.eventDetailPages != Nil)
[self.eventDetailPages removeFromSuperview];
self.eventDetailPages = [[UIPageControl alloc] init];
self.eventDetailPages.numberOfPages = self.evtListData.iTotalPages;
NSLog(@"The total number of pages - %d", self.evtListData.iTotalPages);
CGSize pageControlSize = [self.eventDetailPages sizeForNumberOfPages:self.eventDetailPages.numberOfPages];
NSLog(@"The total width of pages - %f", pageControlSize.width);
self.eventDetailPages.frame = CGRectMake(0, 150, pageControlSize.width,30);
self.eventDetailPages.backgroundColor = [UIColor blackColor];
self.eventDetailPages.center = CGPointMake(self.view.frame.size.width/2, 150);
self.eventDetailPages.clearsContextBeforeDrawing = TRUE;
[self.eventDetailPages addTarget:self action:@selector(pageChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:self.eventDetailPages];
【问题讨论】:
【参考方案1】:在我的情况下,有 4 个点,点仅在单击第 3 个及以上的点时或之后才响应,而反过来,第 2 个和第 3 个点是可选的 [m_pPageControl addTarget:self action:@selector(gotonextPage:) forControlEvents:UIControlEventTouchUpInside];
-(void)gotonextPage:(UIPageControl *) pageControl
int page = m_pPageControl.currentPage;
NSLog(@"PAGEVALUE%d",page);
[m_pScrollView setContentOffset:CGPointMake(page * m_pScrollView.frame.size.width, 0)animated:YES];
我该怎么办?如果我单击第二个点,则当前页面的值不会改变。如果我点击第三个,那么当前页面的值正在改变......
【讨论】:
以上是关于UIPage 控件仅在第 4 页点后响应的主要内容,如果未能解决你的问题,请参考以下文章