First, register the notice inside Viewwillappear.
-(void) Viewwillappear: (BOOL) animated
{
[Super viewwillappear:animated];
Registration screen Rotation message notification
[[Nsnotificationcenter Defaultcenter] Addobserver:self
Selector: @selector (changeframes:)
Name:uideviceorientationdidchangenotification
Object:nil];
}
Initializing controls in viewdidload
After receiving the notification
Change view coordinates after receiving notification
-(void) Changeframes: (nsnotification *) notification
{
CGRect rect = [UIScreen mainscreen].bounds;
if ([[Uidevice Currentdevice] Orientation]==uiinterfaceorientationportrait
|| [[Uidevice Currentdevice] orientation]==uiinterfaceorientationportraitupsidedown)
{
NSLog (@ "Portrait");
_fancytabbar.frame=cgrectmake (rect.size.width-300,rect.size.height-300, 300, 300);
}
Else
{
NSLog (@ "horizontal screen");
_fancytabbar.frame=cgrectmake (rect.size.height-40,rect.size.width-550, 300, 300);
}
}
If the ipad version
Change view coordinates after receiving notification
-(void) Changeframes: (nsnotification *) notification
{
CGRect rect = [UIScreen mainscreen].bounds;
if ([[Uidevice Currentdevice] orientation]==uiinterfaceorientationportrait)
{
NSLog (@ "vertical screen home in the bottom");
_fancytabbar.frame=cgrectmake (rect.size.width-550,rect.size.height-550, 600, 700);
}
else if ([[[Uidevice Currentdevice] orientation]==uiinterfaceorientationportraitupsidedown)
{
NSLog (@ "vertical screen home in the bottom");
_fancytabbar.frame=cgrectmake (rect.size.width-550,rect.size.height-550, 600, 700);
} else if ([[Uidevice currentdevice] orientation] = = Uideviceorientationlandscapeleft) {
NSLog (@ "Horizontal screen home at left");
_fancytabbar.frame=cgrectmake (rect.size.height-300,rect.size.width-800, 600, 600);
} else{
NSLog (@ "Horizontal screen home at right");
_fancytabbar.frame=cgrectmake (rect.size.height-300,rect.size.width-800, 600, 600);
}
}
About the iphone and ipad landscape vertical screen adaptation issues