質問

I get stuck with my cell selection. I have custom cell with UITextView object embedded in. It is not editable, not scrollable, with user interaction enabled. And I can not select cell over this view.

I've tried the same thing but with UITextField object and selection works.

Any ideas how to make it work?

This is the test project. There is just one table view with one cell. There is one text view and one text field in this cell. You can select the cell over the text field and can not over the text view.

役に立ちましたか?

解決

Turn off "User Interaction Enabled" on your text view and the selection will work fine (MainStoryboard.storyboard->Table View Controller->Table View->Table View Section->Custom Table View Cell->Text View). Allowing user interaction on the text view is capturing the taps before the table view cell gets them. Since your text view isn't scrollable or editable, you don't want user interaction enabled.

他のヒント

Just to expound a bit on John Stephen's answer (which is the best as far as I can tell).

I've tried this by subclassing UITextView and overriding canBecomeFirstResponder:

@interface MyTextView : UITextView

@end

@implementation MyTextView

- (BOOL)canBecomeFirstResponder {
  return NO;
}

@end

I've also set editable, selectable, and scrollEnabled to NO:

MyTextView *textView = [MyTextView new];
textView.editable = NO;
textView.selectable = NO;
textView.scrollEnabled = NO;

None of these worked. :(

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top