So I’m attempting to deal with uitabbarcontroller and wanted to have a default tab be selected when the view loads.
I have tried setting the
@property (nonatomic) int selectedIndex;
however this just sets which viewcontroller is being shown, not the actual tabbar being selected
I also tried this line
[self tabBar].selectedItem = [[[self tabBar] items] objectAtIndex:0];
but it crashes as you are not allowed to mutate the tabbar of a tabbarcontroller
Any help with this?
Thanks
So, as discussed in the comments, following code should do what you want:
Alternatively, you can use: