开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜