开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜