ios - UISplitViewController on universal app with Storyboard -
i'm want make app uses uisplitviewcontroler
on ipad (as far understand it's available on ipad) want app universal.
the setup this:
i have uitableview
(as master view) , when select row should display detail view of cell. using storyboard , can't figure out how implement split view ipad.
what easiest way achieve that? thanks.
you don't need 2 storyboards this.you can use them both in single storyboard.for iphone ,we use class swrevealviewcontroller(if new ios coding ..:)) side menu , splitviewcontroller ipad.we can use swrevealviewcontroller ipad well.it depends on requirement.
for universal apps,create viewcontrollers using size classes(usually use height width universal apps ).
change these size classes , create different viewcontrollers ipad , iphones required.in cases height width job.
after creating viewcontrollers,in appdelegate ,using instantiateviewcontrollerwithidentifier
method, load required viewcontroller.
if (ui_user_interface_idiom() == uiuserinterfaceidiompad) { // device ipad running ios 3.2 or later. } else { // device iphone or ipod touch. }
for ipad load splitviewcontroller. , swrevealviewcontroller iphone.
this core basics.if need more information,let me know.
edit
have seen arrowmark ath initial vc(viewcontroller) in storyboard?this vc loaded first after launch screen.in app,i have home screen common both iphone , ipad(using size classes mentioned above).so can set vc initial vc.in case don't have in appdelegate.but if have different home screen ipad,then can make condition check in appdelegate didfinishlaunchingwithoptions
you can load first screen this.you should follow through splitvc tutorilal , swrevealcontroller tutorial set side menu.you should load swrevealvc or splitviewcontroller if first screen contains side menu.
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiompad) { uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; uisplitviewcontroller *split = [storyboard instantiateviewcontrollerwithidentifier:@"splitviewcontroller"]; [appdelegate setrootcontroller:split storyboard:storyboard actiontype:0]; } else if(ui_user_interface_idiom() == uiuserinterfaceidiomphone) { uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; uiviewcontroller *split = [storyboard instantiateviewcontrollerwithidentifier:@"swrevealvc"]; [appdelegate setrootcontroller:split storyboard:storyboard actiontype:-1]; } return yes; } +(void)setrootcontroller:(uiviewcontroller*)controller storyboard:(uistoryboard*)storyboard actiontype:(int) actiontype; { if ( ui_user_interface_idiom() == uiuserinterfaceidiompad && actiontype == 0) { uisplitviewcontroller *splitviewcontroller = (uisplitviewcontroller *)controller; //splitviewcontroller.presentswithgesture = false; uinavigationcontroller *masternavigationcontroller = [splitviewcontroller.viewcontrollers objectatindex:0]; sidemenuviewcontroller *controller = (sidemenuviewcontroller *)masternavigationcontroller.topviewcontroller; controller.splitviewcontroller = splitviewcontroller; splitviewcontroller.delegate = (id)controller; } appdelegate *appdelegate = (appdelegate *)[[uiapplication sharedapplication] delegate]; [uiview transitionwithview:appdelegate.window duration:0.5 options:uiviewanimationoptionallowanimatedcontent animations:^(void) { bool oldstate = [uiview areanimationsenabled]; [uiview setanimationsenabled:no]; appdelegate.window.rootviewcontroller = controller; [uiview setanimationsenabled:oldstate]; } completion:nil]; }
the code may lengthy,but take simple.you can understand logic if u things.
Comments
Post a Comment