i having ipad specific application. want play same on iphone also. app having xib used size class "wregular hregular" many auto layout constraints. want covert wany hany size class. know there 2 way achieve either using auto layout or creating xib file iphone only. want go separate xib files how make files in xcode 7? , how work?
just create new xib file name whatever want give , load uiviewcontroller using following code
viewcontrollername *vc = [[viewcontrollername alloc] initwithnibname:@"" bundle:nil];
in viewcontroller override - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil method in check device iphone or ipad using following code
- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { nsstring * nibnameornil; if ( ui_user_interface_idiom() == uiuserinterfaceidiompad ){ // ipad nibnameornil = @“ipad_xib_name” } else { // iphone } self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; }
this call xib according device type.
Comments
Post a Comment