ios - Proper Way to Open a New Storyboard through UITabBarController -



ios - Proper Way to Open a New Storyboard through UITabBarController -

we working on splitting our main storyboard smaller ones makes source command merging easier. ideas on right approach load new storyboard uitabbar?

here's have far in our custom subclassed uitabbarcontroller:

uitabbaritem *cardstabitem = [self.tabbar.items objectatindex:ktabbarindexcards]; cardstabitem.image = [[uiimage imagenamed:@"navcardsoff"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; cardstabitem.selectedimage = [[uiimage imagenamed:@"navcardson"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; cardstabitem.imageinsets = uiedgeinsetsmake(-5, 0, 5, 0); cardstabitem.titlepositionadjustment = uioffsetmake(0, -5);

i've done same thing before, uitabbarcontroller. in case had storyboard each of tab buttons, though 1 of storyboards had 1 view controller in it. think wether you're using uitabbarcontroller or responding tab bar delegate reply same. each button clicked create determination of storyboard view controller want load in:

uistoryboard *storyboard = [uistoryboard storyboardwithname:@"leftbuttonstoryboard" bundle:[nsbundle mainbundle]]; uiviewcontroller *vc = [storyboard instantiateinitialviewcontroller]; //or uistoryboard *othervc = [storyboard instantiateviewcontrollerwithidentifier:@"cameraviewcontroller"];

then can nowadays it, force it, or whatever.

in case since using uitabbarcontroller done during initialization of controller different buttons.

it come in handy default name of different view controller using in storyboard (the storyboard id), name them after viewcontroller class don't have remember called it.

i recommend avoid using self.storyboard property when trying instantiate view controller because might end situation controller shared between tabs. beingness explicit storyboard you're loading controller can help readability , avoidance of bugs.

edit - more concrete example:

what need set viewcontrollers property of uitabviewcontroller, in init method. example

- (id)initwithcoder:(nscoder *)adecoder { if (self = [super initwithcoder:adecoder]) { uistoryboard *mainstoryboard = [uistoryboard storyboardwithname:@"main" bundle:[nsbundle mainbundle]]; uiviewcontroller *one = [mainstoryboard instantiateviewcontrollerwithidentifier:@"vc1"]; uiviewcontroller *two = [mainstoryboard instantiateviewcontrollerwithidentifier:@"vc2"]; self.viewcontrollers = @[one,two]; } homecoming self; }

you can utilize technique if writing in code or if you're using storyboard. beware if have other view controllers hooked via storyboard you'll loose unless instantiate them there well. can utilize setviewcontrollers: animated: method well.

the code creating custom tab bar items (the buttons @ bottom) should go within individual view controllers , assigned tabbaritem property. uitabbarcontroller utilize property create correctly styled button. if don't provide property default buttons starting 1.

ios objective-c

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -