Reputation: 3196
The scrollview in my main page stop working if I push something to the navigation controller and then pop back to the main page. It works normally if I reopen the application without pushing anything to the navigation controller yet. The scrollview is a horizontal scrollview which extends beyond the frame. I use it to scroll through buttons like when you switch application in iOS (iOS multitasking).
This is the code where I push a new vc
UIViewController *newVC = [[UIViewController alloc] init];
UILabel *label = [[UILabel alloc] initWithFrame:self.view.bounds];
[label setTextAlignment:NSTextAlignmentCenter];
label.text = [NSString stringWithFormat:@"promo %i detail view",[sender tag]];
label.backgroundColor = [UIColor whiteColor];
[newVC.view addSubview:label];
[self.navigationController setNavigationBarHidden:NO animated:NO];
[self.navigationController pushViewController:newVC animated:YES];
when that view controller is popped and navigation controller move back to the main page I hide the navigationBar.
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if(viewController == self){
[self.navigationController setNavigationBarHidden:YES];
NSLog(@"%d", [self.scrollMenuBar isScrollEnabled]);
}
}
checking isScrollEnable return true.
I tried pushing a normal modal view and the same problem occur.
Upvotes: 1
Views: 2052
Reputation: 9688
If you resize the scroll view content size in the viewDidLayoutSubview function it will work again.
- (void) viewDidLayoutSubviews {
[self resizeScrollViewContent];
}
Upvotes: 1
Reputation: 3196
Problem solved by creating the UIScrollview and the button inside it programmatically. Not sure what I did wrong with storyboard, but it's a pain.
Upvotes: 0
Reputation: 20021
Add
[self.scrollbarMenu setScrollEnabled:YES];
in viewdidAppear of main page
Add
[scroll setContentSize:CGSizeMake(width , height)];
Still if it doesnt work 2 possibilities
Upvotes: 0