ios - Crash when retrieving last(6th) tab bar item when programmatically creating UITabBarController -


- (void)setuptabbaritems {      nsmutablearray *itemsarray = [@[] mutablecopy];      uitabbaritem *firsttabbaritem = self.tabbarcontroller.tabbar.items[0];     uitabbaritem *secondtabbaritem = self.tabbarcontroller.tabbar.items[1];     uitabbaritem *thirdtabbaritem = self.tabbarcontroller.tabbar.items[2];     uitabbaritem *fourthtabbaritem = self.tabbarcontroller.tabbar.items[3];     uitabbaritem *fifthtabbaritem = self.tabbarcontroller.tabbar.items[4];     uitabbaritem *sixthtabbaritem = self.tabbarcontroller.tabbar.items[5];  } 

i programmatically creating uitabbarcontroller in appdelegate. have set 6 view controllers before method tab bar controller. in above method, intend set image , title of tab bar items.

there crash on last line i.e., retrieving 6th item of uitabbar items array.

*** terminating app due uncaught exception 'nsrangeexception', reason: '*** -[__nsarrayi objectatindex:]: index 5 beyond bounds [0 .. 4]'

i understand tab bar not take more 6 items expecting last button more tab bar item. unable retrieve it.

but when make uitabbarcontroller in storyboard works many buttons. (taking 6 maximum in case, don't need more)

so ideas?

as know, if add more 5 tabs uitabbarcontroller displays first 4 items , adds standard more item 5th tab. items array not contain more 5 items anyway if try access index beyond 4 (which index of more tab in case) crash.

if need perform operations on more tab (selecting tab example), can use uitabbarcontroller's morenavigationcontroller property.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

Bubble Sort Manually a Linked List in Java -

asp.net mvc - SSO between MVCForum and Umbraco7 -