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
854
7
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?
 

stoopkitty

macrumors member
Jan 26, 2010
62
0
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:
 

KoolStar

macrumors demi-god
Oct 16, 2006
825
9
Kentucky
Whats the reasoning behind the UIButton not being a suitable replacement, if you set its style to custom it appears just as a label.
 

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
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.