Reputation: 147
Hi in my app i have a contact form in that i kept scroll view for the user to scroll the long content but its not working before the i have used same code for my iphone application but now I'm working on ipad its not working.
@property (strong, nonatomic) IBOutlet UIScrollView *scroll;
- (void)viewDidLoad
{
[super viewDidLoad];
[scroll setScrollEnabled:YES];
[scroll setContentSize:CGSizeMake(600, 800)];
}
please tell me where I'm doing wrong why its not working.
Thanks.
Upvotes: 0
Views: 471
Reputation: 25692
- (void)viewDidLoad
{
[super viewDidLoad];
// Make scroll view size to main view size
scroll.frame = self.view.bounds;
[scroll setScrollEnabled:YES];
//Double the height of iPad or Iphone
[scroll setContentSize:CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height*2)];
//Or
[scroll setContentSize:CGSizeMake(self.view.bounds.size.width, your Large Height)];
}
Upvotes: 0
Reputation: 2918
The content size should be greater than the frame size of the scrollview. Only then the scrolling will be enabled.
Upvotes: 1