I have a UIScrollview which loads fine, displays fine, does everything just fine. I then push another view controller, call it VC2, which also works fine. From VC2 I pop to go back to the UIScrollview and here is the weird behavior… when the UIScrollview comes back, the first (I am guessing) 300 pixels from the top are cut off. I can still see the content if I pull the page down but obviously that’s not working for me. Anyone have any thoughts?
Here is the code:
This is creating the ScrollView:
-(IBAction)startNewSearch:(id)sender
{
NewSearch *VCscrollView = [[NewSearch alloc] init];
[[self navigationController] pushViewController:VCscrollView animated:YES];
}
The ScrollView
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
scrollView.contentSize = CGSizeMake(320, 890);
[scrollView setContentOffset:CGPointMake(0, 0) animated:NO];
[scrollView flashScrollIndicators];
}
-(void)viewWillAppear:(BOOL)animated
{
scrollView.frame = CGRectMake(0, 0, 320, 890);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
IBAction which calls VC2 from within the ScrollView:
-(IBAction)previewSearch:(id)sender
{
VCcontactServer *VC2 = [[VCcontactServer alloc] init];
[[self navigationController] pushViewController:VC2 animated:YES];
}
Credit for the correct answer goes to Andrey Soloviev but unfortunately he did not post for me to give him credit. Adding the code:
fixed the problem as described. The root of the problem ended up being a little more complex and outside of the scope of my question.