1

My code is [scrllView setContentSize:CGSizeMake(self.view.bounds.size.width, 1000)]; so that its width appear on whole screen. But when I am changing the orientation to landscape, its width is not adjusting. I think it is not working because i am doing it in viewDidLoad method, .So it will calulate the width only once. But what will be the possible solution of this. scrLlView Should adjust width

Bhupesh Kumar
  • 369
  • 2
  • 18

1 Answers1

2

try this

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
{
 //change sub view of scrollview accordingly to orientation
 if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
     yourScrollView.frame = CGRectMake(0,0,320,460);
     yourScrollView.contentSize = CGSizeMake(320,460);//change accordingly
 else
     yourScrollView.frame = CGRectMake(0,0,480,300);
     yourScrollView.contentSize = CGSizeMake(480,500); //change accordingly

 return YES;
}

[yourScrollView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleHeight];

additional reference

Community
  • 1
  • 1
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143