1

I was trying to follow this post to get pixel position of a certain word in my UITextView, but the following code:

UITextPosition *beginning = cell.textView.beginningOfDocument;

caused my App to crash (seems to be in iOS4 only, but according to documentations UITextInput beginningOfDocument should be available since iOS3.2). I tried to debug the issue and get the following output:

(gdb) po cell
<ReadTableViewCell: 0x1bf25d60; baseClass = UITableViewCell; frame = (0 0; 320 44); userInteractionEnabled = NO; tag = 1248776; layer = <CALayer: 0x1bf25d20>>
(gdb) po [cell textView]
<UITextView: 0x1bf26810; frame = (5 4; 309 121); text = 'Subject Header

Detailed Content...'; clipsToBounds = YES; layer = <CALayer: 0x1bf26650>; contentOffset: {0, 0}>
(gdb) po [[cell textView] beginningOfDocument]
Target does not respond to this message selector.
(gdb)

Could somebody please kindly give me some hint as how to fix or avoid this? Thanks in advance!!

Community
  • 1
  • 1
Asususer
  • 128
  • 1
  • 3
  • 12

1 Answers1

1

UITextInput was definitely available since iOS3.2, but sadly UITextView conformed to UITextInput as of iOS5.0. It used to use the UITextInputTraits protocol.

There's some more info on how to adjust to work on iOS4 in this thread:

Issue in UITextView beginningOfDocument in iOS 4.3

Community
  • 1
  • 1
Kelly
  • 1,096
  • 12
  • 22