Following this example, I wanted to move the button to a different place on the bar, between the new tab button and the wrench icon. When I add the button, if I look at the list of button items before and after, I can see that it has been added, but it's not visible. How can I make it show?
My modified code:
# coding: utf-8
from objc_util import *
UIApplication = ObjCClass('UIApplication')
UIBarButtonItem = ObjCClass('UIBarButtonItem')
@on_main_thread
def main():
global tabVC,overviewItem
rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
tabVC = rootVC.detailViewController()
tabVC.tabCollectionView().collectionViewLayout().itemSize = CGSize(328,200)
tabVC.tabCollectionView().contentInset = UIEdgeInsets(58,0,0,0)
overviewItem = UIBarButtonItem.alloc().initWithImage_style_target_action_(UIImage.imageNamed_('ShowTabs'), 0, tabVC, sel('showTabOverview:'))
#Add the item
rightItems=list(tabVC.navigationItem().rightBarButtonItems())
print tabVC.navigationItem().rightBarButtonItems()
rightItems.insert(-1,overviewItem)
rightItems=ns(rightItems)
rightItems.init()
tabVC.navigationItem().set_rightBarButtonItems_(rightItems)
print tabVC.navigationItem().rightBarButtonItems()
#tabVC.persistentLeftBarButtonItems = [overviewItem]
tabVC.reloadBarButtonItemsForSelectedTab()
if __name__ == '__main__':
main()
Mentioning people who might be able to help me:
@omz @JonB @filippocld