iosobjective-cios-universal-appautoresizingmask

Over write UI component's autoresizingmask generated by storyboard in code iOS 8


I am porting my iPhone app into Universal app. I am supporting only portrait mode for iPhone but for iPad only Landscape mode is supported. I want to keep my few views only autoresizable in only height for iPad whereas for iPhone its completely autoresizable.

In storyboard i have added all autoresizablemask and for iPad i am using viewDidLoad to override autoresizingMask for the view which i want to be autoresizable only in iPad as shown in below code:

self.view_MainBackGround.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;

but its not working in iOS 8, i want to know what i am doing wrong, where should i set autoresizingMask for few views, which will be resizing in all direction for iPhone but only height for iPad.


Solution

  • I ended up setting view_MainBackGround frame in viewWillAppear: since setting frame will not work in viewDidLoad because when the view loads its actually in landscape size and changes in portrait mode when it appears after loading.