开发者

Getting a reference to a UIBarItem in a UIToolBar

开发者 https://www.devze.com 2023-02-08 08:55 出处:网络
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

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

精彩评论

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

关注公众号