0

UIPageControl をセットアップしようとしていますが、currentPage;を設定する必要があります。私は次のものを持っていますが、値がself.pageControl.currentPageに割り当てられると、正しい値であっても常に0になります。UIPageControl を使用するのはこれが初めてで、本当に基本的なものが欠けていると思います。おそらく常にどこかで 0 にリセットされています。thx事前に

これが私のコードです

- (void)scrollViewDidEndDecelerating:(UIScrollView *)aScrollView
{
    self.pageControl.currentPage = (int) floor((self.scrollView.contentOffset.x + 0.25)/320.0f);
    int this_page=(int)(self.scrollView.contentOffset.x + 0.25)/320.0f;
  self.pageControl.currentPage=this_page;
  NSLog(@"here is property %d", self.pageControl.currentPage);
  NSLog(@"here is this_page %d", this_page);
  self.pageControl.currentPage=4;
  NSLog(@"here is property after manual set %d", self.pageControl.currentPage);

}

および私の NSLog 出力。

2013-03-03 10:19:14.204 Lt[32045:11303] here is property 0
2013-03-03 10:19:14.206 Lt[32045:11303] here is this_page 1
2013-03-03 10:28:03.993 Lt[32209:11303] here is property after manual set 0
2013-03-03 10:19:15.449 Lt[32045:11303] here is property 0
2013-03-03 10:19:15.449 Lt[32045:11303] here is this_page 2
2013-03-03 10:28:03.993 Lt[32209:11303] here is property after manual set 0
4

1 に答える 1

1

ほとんどのself.pageControl場合、nil です。つまり、コンセントを適切に接続していません。または、ページ コントロール自体が正しく構成されていません。たとえば、 を設定していませんnumberOfPages

ところで、iOS 6 でページ コントロールとページネーション スクロール ビューを調整する最も簡単な方法は、代わりに UIPageViewController を使用することです。

于 2013-03-03T18:28:10.207 に答える