开发者

Objective-C: How to dynamically create GUI objects?

开发者 https://www.devze.com 2023-01-14 17:31 出处:网络
I`m really new in Objective-C and Mac OSX programming. Can someone give me simple example for the next task:

I`m really new in Objective-C and Mac OSX programming.

Can someone give me simple example for the next task: I have array of strings (for example ('one','two','three','four')) in my app GUI each string should be represented by row, each row should has Label(with text of string) a开发者_StackOverflow社区nd CheckBox. Number of strings in array may be different. How i can dynamically create this GUI objects?

It is like in Transmission app, when you open torrent file and window opens with list of files and checkboxes


D you want to create a table? So what you are looking for is a UITableView object whose rows will be dynamically created after you set the 'data source'(in this case the data source can be your viewController that encapsulates that string array) from which it will get the data dynamically.

You'd better have a look at some documentation about UITableView and their programming

If this is not what you are looking for, you can accomplish your goal by creating many UIView dynamically, adding content to them (UILabels, etc) and position them one after the other on the main UIView as subview calculating their frame position and dimension

0

精彩评论

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