Getting a reference to a UIBarItem in a UIToolBar
I have constructed my GUI in interface builder, with at toolbar + bar items. Now I need a reference to the buttons (UIBarItems) in code, and I try with the viewWithTag method (as I have given the bar items tag numbers in IB).
Here is my code, but it always returns null!
UIBarItem *backButton = (UIBarItem *)[s开发者_Python百科elf.toolbar viewWithTag:1];
NSLog(@"backButton: %@", backButton); // returns nil
you should look for the items in the 'items' property and not in subviews.
精彩评论