开发者

XCode/Objective-C, load buttons (and other UI elements) at runtime

开发者 https://www.devze.com 2023-03-17 10:22 出处:网络
Is it开发者_Go百科 possibile to load buttons at runtime without using .xib files and connect the buttons to class properties anyway (without drag&drop)?With the \"load without .xib\" statement do

Is it开发者_Go百科 possibile to load buttons at runtime without using .xib files and connect the buttons to class properties anyway (without drag&drop)?


With the "load without .xib" statement do you mean "instantiate in the code", right? in such case the answer is "yes, of course":


// interface
@property (retain) UIButton *myButtonProperty;

// implementation

UIButton *tmpButton = [UIButton buttonWithType:...];
...
self.myButtonProperty = tmpButton;


Yes, it is. You can create button object and add it to a view. More details can be found here.

0

精彩评论

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

关注公众号