Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BarryK88

macrumors member
Original poster
Mar 1, 2011
31
0
I'm making an scrollview within a view of the iPad. It should switch positions after rotating. It works however when I rotate my device twice the scroller gets out of my screen.

Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

	if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
		interfaceOrientation == UIInterfaceOrientationLandscapeRight){
		interfaceOrientation == UIInterfaceOrientationLandscapeLeft;

			backgroundImage.image = [UIImage imageNamed:@"landscape.png"];

			
		
			scroller.transform = CGAffineTransformMakeRotation(M_PI/2);
		
			
			scroller.frame = CGRectMake(0, 108, 130, 750);
			scroller.contentSize = CGSizeMake(1040, 130);
			scroller.scrollEnabled = YES;
}

if(interfaceOrientation == UIInterfaceOrientationPortrait ||
	   interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
		interfaceOrientation == UIInterfaceOrientationPortrait;
		
backgroundImage.image = [UIImage imageNamed:@"portrait.png"];
		
		scroller.transform = CGAffineTransformMakeRotation(M_PI*2);
		scroller.frame = CGRectMake(0, 870, 768, 128);
		scroller.contentSize = CGSizeMake(940, 128);			
		}

Think I'm making a mistake with my angle calculations. However i saw the following on the UIView CLass reverence about the transform property " if this property is not the identity transform, the value of the frame property is undefined and therefor should be ignored"

However I still can't figure it out. Some help would be realy appreciated.
 
Last edited by a moderator:
is there a reason you don't like to use IB? i think it is so much easier to deal with rotation and such via the pictoral interface builder.
 
It's not possible to do this in the interface builder because the sizes of the scrollers are a bit different same goes for the location in landscape view.
Landscape -> (0, 108,) with a Width and Height (130, 800)
Portrait -> (0, 870) with a Width and Height (768, 130)

When I rotate this with IB the scroller stays horizontal in stead of a vertical one in Landscape view. it's also impossible to get the right coordinates.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.