2

I have a UIViewController which contains several UITableViews. You can swipe through the UITableViews using a pagecontrol.

Now in another UIViewController you can navigate to a certain UITableView. I do it as following. In my prepareForSegue in the viewController I set a pageNumber. Then In my other UIViewController I am doing this.

-(void)jumpToPage:(NSNumber *)page{
    NSLog(@"jump to page");
    float offset=30;
    float height = self.scrollView.bounds.size.height;
    float width = 320 - (2*offset);
    int pagee = [page intValue] - 1;
    float x  = (320 * pagee) + offset;

    NSLog(@"X is %f",x);
    [self.scrollView scrollRectToVisible:CGRectMake(x, 0, width , height) animated:NO];

}

This is causing that my UIScrollView is not scrollable anymore. I don't know if it is important but this is what I'm doing in my viewWillAppear

    -(void)viewWillAppear:(BOOL)animated{
        // Set up the content size of the scroll view
        CGSize pagesScrollViewSize = self.scrollView.frame.size;
        self.scrollView.contentSize = CGSizeMake(pagesScrollViewSize.width * self.pageStages.count, pagesScrollViewSize.height);
        [self loadVisiblePages];
        [self updateDay];

}

Can anybody help me with this??

EDIT

I've added this at the end of the jumpToPage method

   NSLog(@"content size is %d",320 * self.pageStages.count);
    self.scrollView.contentSize = CGSizeMake(320 * self.pageStages.count, self.scrollView.bounds.size.height);

But this has still no effect.

4

2 回答 2

7

您可以根据您的需要设置框架,它将通过页面控制动画到下一个视图

 [scrollview scrollRectToVisible:CGRectMake(320,  80,320, 350) animated:YES];
于 2013-06-21T08:18:21.683 回答
0

滚动视图的内容大小应该大于滚动视图框架。如果框架之外没有内容,滚动视图将不会滚动。

因此,您可以尝试增加内容大小的高度(垂直滚动),反之亦然。

如果您观察到viewWillAppear内容高度与滚动框架相同。我怀疑这可能会影响垂直滚动。

希望这可以帮助

于 2013-06-20T08:07:43.460 回答