Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
939
41
Tokyo, Japan
I have a tableview and there are UILabel or UITextView in cell, I want to handle action event when I click word I UILabel or UItextView, how can I do?
 
As far as I know, touches will pass through to the cell if you use a UILabel, and if you use a UITextView which has no scrolling. Use NSString's method sizeWithFont:constrainedToSize:lineBreakMode: to figure out the size you need the UILabel to be to see all of the text and change the size of your UITableViewCell accordingly with tableView:heightForRowAtIndexPath:
 
Whats the reasoning behind the UIButton not being a suitable replacement, if you set its style to custom it appears just as a label.
 
I have a tableview and there are UILabel or UITextView in cell, I want to handle action event when I click word I UILabel or UItextView, how can I do?

Set the label's userInteractionEnabled flag to YES.

Attach a tap gesture recognizer.

Have the tap gesture recognizer send a message to the view controller.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.