About the iphone and ipad landscape vertical screen adaptation issues

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.