我有一個UIPageControl。當我點擊一個點來改變頁面時,沒有任何反應。第二個點不會突出顯示。UIPageControl不響應觸摸,不改變點
它工作正常,但是,當我滾動我的UIScrollView。在這種情況下,第二個點將突出顯示。
pageControl = [[UIPageControl alloc] init] ;
pageControl.center = CGPointMake(160.0f, 430.0f);
pageControl.numberOfPages=nPages;
pageControl.currentPage=0;
pageControl.hidesForSinglePage = YES;
pageControl.userInteractionEnabled =YES;
[pageControl addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:pageControl];
當我改變pageControl Value的時候應該調用它,但是它不會被調用,因爲它不響應觸摸。
- (void) pageTurn: (UIPageControl *) aPageControl
{
int whichPage = aPageControl.currentPage;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
sv.contentOffset = CGPointMake(320.0f * whichPage, 0.0f);
[UIView commitAnimations];
}
這不起作用。我將頁數設置爲7.當我點擊點2和3時,它沒有響應。我點擊了點4,它響應並保持點擊它直到我到達最後一個點,即7.現在,當我點擊點2和3時,它響應! – 2011-05-12 13:45:20
@pratikshabhisikar:答案是專門解決Alex L的問題。當然,這不是也不可能成爲每個UIPageControl問題的答案。如果它不能解決你的具體情況,你的問題的原因和解決方案必須有所不同,並且不能證明它是失敗的。 – Anna 2011-05-12 14:06:31
我在做[[UIPageControl alloc] init]時沒有設置幀,因爲我總是認爲UIPageControl的大小會自動調整。我錯了! [[UIPageControl alloc] initWithFrame:CGRect]取得了訣竅。 TY! – DZenBot 2012-12-09 06:57:22