ios7 - Can i update value of label by long press on it - iOS -
I write a simple application with Xcode 5 on the iPhone iOS7 device. I have a label that increases with the +/- button, but I want to give the user the option to enter their numbers on this label. How can I do this with a long press identifier? Thank you.
use a Add a You have to see that your view controller corresponds to : This is the method that you will call upon when the text view is pressed for a long time: Apply this method to When you end the editing of text view When you press Return to dismiss the keyboard: UILongPressGestureRecognizer and a
UITextView .
UILongPressGstureRecognizer property to your view controller:
@propertyUILongPressGestureRecognizer * gestureRecognizer;
UITextViewDelegate and
UIGestureRecognizerDelegate protocol:
@interface view controller: UIViewController & lt; UITextViewDelegate, UIGestureRecognizerDelegate & gt;
viewDidLoad in
self.textView.editable = NO; Self.textView.delegate = self; Self.gesturerecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget: Self-action: @Selector (TextualGuoder :)]; Self.gesturerecognizer.delegate = self; [Self.textView addGestureRecognizer: self.gr];
- (zero) text message langard: (UILongPressGestureRecognizer *) sender {Self.textView.editable = Yes; [Self.textViewFirstResponder]; }
UIGestureRecognizerDelegate
- (BOOL) gesture: Indicator: (UIGestureRecognizer *) Gesture Should be identified with synonymsChandler: (UIGestureRecognizer *) Other GestureRecognizer {If (self.gestureRecognizer == gestation provider) {return yes; } no return; }
- (zero) text viewideiding: (UITxviewview) * Text view {self.textView.editable = NO; }
- (BOOL) TextView: (UITextView *) textView should changeChangeInRange: (NSR ) Limit replacement text: (NSString *) Text {if ([text isEqualToString: @ "\ n"]) [textView resignFirstResponder]; // or [textView end editing: yes] return yes; }
Comments
Post a Comment