开发者

UIButtonTypeRoundedRect as an accessoryView

开发者 https://www.devze.com 2023-01-01 03:43 出处:网络
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 c

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

精彩评论

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