简体   繁体   中英

orientation change working strangely from landscape to portrait

after creating the app in landscape mode . I am adding the menu view for my application in portrait view
but when I tried to change the view from both in xib and programatically
the view changed but the mobile simulator is still shown as landscape view along with showing the previous view background
I have gone through many of the question regarding the orientation but nothing seems to work for me

here is the pic reference of app
在此处输入图片说明

and the code for creating the button is
easy button code is

easee = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[easee addTarget:self 
            action:@selector(easy:)
  forControlEvents:UIControlEventTouchUpInside];
[easee setImage:[UIImage imageNamed:@"radioButtonDisabled.png"] forState:UIControlStateNormal];
easee.frame = CGRectMake(85.0, 86.0, 22.0, 22.0);
[self.view addSubview:easee];

The view frame does not rotate when the device rotates. Only the view bounds within the frame rotates. If the placement of your UIView objects are different in portrait and landscape and you have already tried struts and springs and that is not enough, then you have to programmatically code their position. In that case, use bounds.

easee.bounds = CGRectMake(85.0, 86.0, 22.0, 22.0);

Keep in mind, that you will need to have different code (coordinates) for portrait and Landscape depending on the object positions in the view, in the orientation.

Please read the view PG: http://developer.apple.com/library/ios/#documentation/windowsviews/conceptual/viewpg_iphoneos/WindowsandViews/WindowsandViews.html

it will give you a good understanding of view, bounds, frames, etc...

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM