I'm having a problem with contentInset
not working for a UIScrollView to work with a keyboard popup. It kind of works: for some reason I need large numbers (maybe above the view's height?) for it to do anything, despite all documentation of contentInset
showing small numbers like 40.0
(e.g. for a bar), or the keyboard height.
I've reproduced the problem on a brand new application by the following steps:
Here is the code for the ViewController:
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@end
@implementation ViewController
- (IBAction)button:(id)sender {
self.scrollView.contentInset = UIEdgeInsetsMake(0.0, 0.0, 600, 0.0);
}
@end
What am I missing / why do I need large numbers?
Check that self.scrollView.contentSize
is set properly. If contentSize.height
is 0 (as will be the case following your steps), then a large inset is required.
Try adding [self.scrollView setContentSize: CGSizeMake(320, 568)];
to the button method and you'll notice that your inset will now behave as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With