开发者

how to add a label and button in the same line in a tableview

开发者 https://www.devze.com 2022-12-26 00:12 出处:网络
I am using UICatalog example and trying to find whether it is possible to add a labe开发者_如何学Cl next to a button. Please let me know how to approach this problemThere are a couple of ways to do th

I am using UICatalog example and trying to find whether it is possible to add a labe开发者_如何学Cl next to a button. Please let me know how to approach this problem


There are a couple of ways to do this, but I tend to create a UITableViewCell derivative with an associated XIB file. Modify the XIB in Interface Builder to include the button and the label. Hook those objects up to IBOutlets and IBActions in your UITableViewCell class.

When you implement your cellForRowAtIndexPath you can grab the top level object from your UITableViewCell XIB file like this:

NSArray * topLevelObjects = [[NSBundle mainBudnle] loadNibNamed:@"YourCellNib" owner:self options:nil];
cell = [topLevelOjects objectAtIndex:0];

You can then cast your cell object to your UITableViewCell class:

YourCellClass * thingCell = (YourCellClass*)cell;

You can then use the YourCellClass to control (and receive events from) the cell in the UITableView.

0

精彩评论

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