Drag and drop a highlighted text within an iphone TextView
I'm trying to highlight a word then drag and drop it anywhere within the iphone UITextView. Can 开发者_开发知识库anyone help? Thank you much!
Ok, you're going to run into two problems.
problem 1) you need to add a gesture for a drag and drop. Defining a new gesture that will select the a word and drag it should be too hard.
http://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html#//apple_ref/doc/uid/TP40009541-CH6-SW13
this portion of the article should lead you in the right direction.
problem 2) You can't just add the gesture to the UITextView when you load. When you select a UITextView it will become the first responder by default. When the keyboard is loaded the UITextView class will add Gestures to the TextView to handle the standard text edit gestures. After this the UITextViewTextDidBeginEditingNotification will get sent you should then add your gesture to the textview at this point. Otherwise it will get over written.
I hope this leads you in the right direction. Good luck.
精彩评论