开发者

UIButtonTypeRoundedRect as an accessoryView

I have a table view and I want to put a label on the right of each cell, so in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath I'm having some code like this

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.text = @"title";
cell.accessoryView = button;

However, the button is not displaying at all. Anyone know why? I am sure that 开发者_如何转开发the declaration is correct, because if I replace the button declaration with

UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

then the button appears, which make me think that the rounded rectangle should also appear.


Try checking if the button's frame is equal to CGRectZero and if so, set it to an appropriate value.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜