#import "AutosizeViewController.h"
@implementation AutosizeViewController
@synthesize button1;
@synthesize button2;
@synthesize button3;
@synthesize button4;
@synthesize button5;
@synthesize button6;
-(void)willAnimateSecondHalfOfRotationFromInterfaceOrinetationUIInterfaceOrientation)fromInterfaceOrientation durationNSTimeInterval)duration {
UIInterfaceOrientation toOrientation = self.interfaceOrientation;
[UIView beginAnimations"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
@implementation AutosizeViewController
@synthesize button1;
@synthesize button2;
@synthesize button3;
@synthesize button4;
@synthesize button5;
@synthesize button6;
-(void)willAnimateSecondHalfOfRotationFromInterfaceOrinetationUIInterfaceOrientation)fromInterfaceOrientation durationNSTimeInterval)duration {
UIInterfaceOrientation toOrientation = self.interfaceOrientation;
[UIView beginAnimations"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