Reputation: 2777
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.
Upvotes: 2
Views: 7331
Reputation: 6570
You can set frames according to ur needs and it will animate to next view with page control
[scrollview scrollRectToVisible:CGRectMake(320, 80,320, 350) animated:YES];
Upvotes: 7
Reputation: 699
The content size of the scroll view should be greater than the scroll view frame.If there is no content beyond the frame scroll view won't scroll.
Hence you can try increase the height of the content size (for vertical scrolls) and vice-versa for horizontal.
If You observe in your viewWillAppear
the content height is the same as the scroll frame.I suspect this might affect the vertical scroll.
Hope this helps
Upvotes: 0