xcode - I want to go to a specific tab in a UITabBarController from a view controller -


first of all, let me i'm absolute beginner, please forgive me if stupid questions asking. , let me add i've spent hours/days trying figure out how solve problem - including extensive searches on stackoverflow (maybe answer somewhere , don't search :)...

but, let's continue: have small (?) problem xcode storyboard project. project looks this:

navigation controller -> view controller 0 -> tab bar controller -< view controller 1, view controller 2, view controller 3.

when user pushes 'button #2' in view controller 0, i'd him/her jump directly 'view controller 2'.

would possible @ all, , if code should use , excatly should put it.

hope out there newbie out :)

regards, ulrik

yes possible. may show view controller other. should add segue button #2 view controller 2. (i assume have controllers in single storyboard)

update: above solution show view controller 2 without tab bar controller.

hard tell in details without seeing actual code. more details may refer these documents:

probably you'll come more concrete question.

update if want preselect desired view controller inside tabbar controller may use following code sketch. here can programmatically initiate segue , desired pre-initialization inside prepareforsegue:sender: method.

static nsstring * const kshowtabsegueid = @"showtab";  @interface viewcontroller ()  - (ibaction)buttononepressed; - (ibaction)buttontwopressed; - (ibaction)buttonthreepressed;  @end  @implementation viewcontroller  - (ibaction)buttononepressed {     [self performseguewithidentifier:kshowtabsegueid                               sender:@0]; }  - (ibaction)buttontwopressed {     [self performseguewithidentifier:kshowtabsegueid                               sender:@1]; }  - (ibaction)buttonthreepressed {     [self performseguewithidentifier:kshowtabsegueid                               sender:@2]; } - (void)prepareforsegue:(uistoryboardsegue *)segue                  sender:(id)sender {     if ([segue.identifier isequal:kshowtabsegueid]) {         nsnumber *indextoshow = sender;         uitabbarcontroller *tabbar = segue.destinationviewcontroller;         [tabbar setselectedindex:indextoshow.unsignedintegervalue];     } }  @end 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -