开发者

UItableViewCell - don't allow to select the cell, but can still press buttons inside it?

Can you add a button as a subview to a uitableview cell and have that clickable, but not the cell itself. ie: I don't want the selected view to come up. Obvs I can just not have the cell disclose anywhere, but I don't want it to look "selected" when someone taps it.

Setting user interaction enabled to NO makes the whole thing unenabled, including the buttons.

Any ideas?

Than开发者_开发技巧k you.

Tom


cell.selectionStyle = UITableViewCellSelectionStyleNone;

This will prevent the cell to highlight for a bit before the willSelect returns nil


implement this delegate method:

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    return nil;
}

and set the UITableViewCells selectionStyle property to UITableViewCellSelectionStyleNone


Just select the option "no selection" on the attributes inspector like in the image

UItableViewCell - don't allow to select the cell, but can still press buttons inside it?


Or you could uncheck the user interaction in the Attributes inspector of the cell interface file. Localice the section: "View" and the subtitle: "Interaction", here you have: "User Interaction Enabled".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜