hackiftekhar / IQKeyboardManager

Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.
MIT License
16.46k stars 2.41k forks source link

Swift iOS 8.4 - How to show Popover when click in UITextView with IQKeyboardManager #253

Closed diegothucao closed 9 years ago

diegothucao commented 9 years ago

Dear Friends, I want to show popover or customized Warring message when I click on a specific UITextView, I used:

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField { if (textField == customWorkTextField) { if (textField.isAskingCanBecomeFirstResponder == NO) { //Do your work on tapping textField. [[[UIAlertView alloc] initWithTitle:@"IQKeyboardManager" message:@"Do your custom work here" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show]; }

    return NO;
}
else    return YES;

}

How to do in in Swift and iOS 8.4 ?

Thanks,

Thu

hackiftekhar commented 9 years ago

Put conditions just like sample code doing, and show popover where alert view is showing ( //Do your work on tapping textField.).

diegothucao commented 9 years ago

textFieldShouldBeginEditing is not existed in Swift

hackiftekhar commented 9 years ago

It exists, do you have any reference to point-out that textFieldShouldBeginEditing is not exist in swift?

func textFieldShouldBeginEditing(state: UITextField) -> Bool { return false }

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextFieldDelegate_Protocol/

hardikdevios commented 9 years ago

@diegothucao you are approaching a Wrong delegate You are using UITextView and tried to call the delegation of UITextField but the correct method is,

textViewShouldBeginEditing(_:)

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextViewDelegate_Protocol/#//apple_ref/occ/intfm/UITextViewDelegate/textViewShouldBeginEditing:

hackiftekhar commented 9 years ago

@hardikdevios You are right! @diegothucao you are using wrong delegate method.

diegothucao commented 9 years ago

Thanks for you helps. I have done with it.

Thanks