Reputation: 183
I've read a few posts that have the same problem as me. My scroll view is not behaving very well with auto layout. I uncheck auto layout and it's fine, however I have two buttons (next and previous) that need to stay at the bottom of the superview which I don't know how to without autolayout D: I have an image view in the scroll view and its not showing the whole image it ends halfway through showing the image. I have the image view set for 300 width and 500 height.
Would anyone be able to help me out with how to programmatically set "bottom space to super-view" constraints on objects? Alternatively, I'm sure there's some way to accomplish this using auto layout apple wouldn't do that to me lol.
what i've tried:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(320, 2000)];
}
I've also set height and width constraints and played around with sizing until I couldn't take it anymore. What it does is it just scrolls a tiny tiny bit and then that's it. I suppose programmatically setting the constraints for my buttons and unchecking autolayout is an option but there must be some way accomplish this with auto layout. Any suggestions greatly appreciated.Thanks!
Upvotes: 2
Views: 1183
Reputation: 155
This code u can use in iPad also:
in .m file
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
scrollViewMain.frame = CGRectMake(0, 0, 768, 815);
[scrollViewMain setContentSize:CGSizeMake(768, 1040)];
}else {
scrollViewMain.frame = CGRectMake(0, 0, 320, 370);
[scrollViewMain setContentSize:CGSizeMake(320, 510)];
}
Upvotes: 0
Reputation: 183
Interesting. Resolved it by selecting the bottom to super view constraint and checked the "standard" check box next to the "Constant" field and let it auto set, and it scrolled! yaaaay. I guess auto layout is your friend once you learn how to talk to it ^^
Upvotes: 1