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

henktade

macrumors newbie
Original poster
Jan 30, 2009
17
0
#import "AutosizeViewController.h"

@implementation AutosizeViewController
@synthesize button1;
@synthesize button2;
@synthesize button3;
@synthesize button4;
@synthesize button5;
@synthesize button6;

-(void)willAnimateSecondHalfOfRotationFromInterfaceOrinetation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration {

UIInterfaceOrientation toOrientation = self.interfaceOrientation;
[UIView beginAnimations:mad:"move buttons" context:nil];

if(toOrientation == UIInterfaceOrientationPortrait || toOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
button1.frame = CGRectMake(20, 20, 125, 125);
button2.frame = CGRectMake(175, 20, 125, 125);
button3.frame = CGRectMake(20, 168, 125, 125);
button4.frame = CGRectMake(175, 168, 125, 125);
button5.frame = CGRectMake(20, 315, 125, 125);
button6.frame = CGRectMake(175, 315, 25, 25);
}
else
{
button1.frame = CGRectMake(20, 20, 125, 125);
button2.frame = CGRectMake(20, 155, 125, 125);
button3.frame = CGRectMake(177, 20, 125, 125);
button4.frame = CGRectMake(177, 155, 125, 125);
button5.frame = CGRectMake(328, 20, 125, 125);
button6.frame = CGRectMake(328, 155, 100, 100);
}
[UIView commitAnimations];
}

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
//(interfaceOrientation == UIInterfaceOrientationPortrait ||
// interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ||
// interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
// interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[button1 release];
[button2 release];
[button3 release];
[button4 release];
[button5 release];
[button6 release];
[super dealloc];
}

@end

hello .. can any body advice me what is wrong with this code. it runs but the button do not change there position in the way I want them to change as discribed in the willAnimateSecondHalfOfRotationFromInterfaceOrinetation method.

tanks in advance :)
 

henktade

macrumors newbie
Original poster
Jan 30, 2009
17
0
guys say some thing

guys!!!! say some thing.. is kind of urgent...
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
Here's Apple's primer on view geometry.

Basically the coordinate system remains with its origin in the top left-hand corner on rotation, so you need to work out where you want your buttons in the new coordinate system.

You also don't seem to have a case in your willAnimateSecondHalfOfRotationFromInterfaceOrinetation method to handle landscape mode.

More fundamentally, "Orientation" is spelt wrong in "willAnimateSecondHalfOfRotationFromInterfaceOrinetation" – are you sure it's actually being called?
 

henktade

macrumors newbie
Original poster
Jan 30, 2009
17
0
Here's Apple's primer on view geometry.

Basically the coordinate system remains with its origin in the top left-hand corner on rotation, so you need to work out where you want your buttons in the new coordinate system.

You also don't seem to have a case in your willAnimateSecondHalfOfRotationFromInterfaceOrinetation method to handle landscape mode.

More fundamentally, "Orientation" is spelt wrong in "willAnimateSecondHalfOfRotationFromInterfaceOrinetation" – are you sure it's actually being called?

tanks Jnic it is ok now.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.