Am facing this problem ever since i upgraded to XCODE 4.5.
I have various UI elements
UIButton *button1;
UIButton *button2;
UIButton *button3;
- (void)viewDidLoad
{
button1 =[[UIButton alloc]init ];
button1.backgroundColor=[UIColor yellowColor];
[self.view addSubview:button1];
button2 =[[UIButton alloc]init ];
button2.backgroundColor=[UIColor yellowColor];
[self.view addSubview:button2];
button3 =[[UIButton alloc]init ];
button3.backgroundColor=[UIColor yellowColor];
[self.view addSubview:button3];
}
whose frames are declared in
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation==UIInterfaceOrientationPortrait ||[interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown )
{
button1.frame=CGRectMake(10,10,10,10);
button2.frame=CGRectMake(10,30,10,10);
button3.frame=CGRectMake(10,50,10,10);
}
if(interfaceOrientation ==UIInterfaceOrientationLandscapeLeft ||interfaceOrientation==UIInterfaceOrientationLandscapeRight)
{
button1.frame=CGRectMake(20,10,10,10);
button2.frame=CGRectMake(20,30,10,10);
button3.frame=CGRectMake(20,50,10,10);
}
return YES;
}
but the frames are not set in Xcode 4.5..
in the previous versions it worked fine.
i need auto sizing badly in my app. so help me.
You should need to implement new methods(introduced in ‘ios 6’ ) in viewController for orientation
}
And Modify You Code place your code inside the in Below Method
Also check your window, you need to add the controller on window as rootviewController rather than addSubview like below
self.window.rootViewController=viewController;