123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- //
- // TextFieldViewController.m
- // KeyboardTextFieldDemo
- #import "TextFieldViewController.h"
- #import "IQKeyboardManager.h"
- #import "IQDropDownTextField.h"
- #import "IQUIView+IQKeyboardToolbar.h"
- #import "IQUITextFieldView+Additions.h"
- @interface TextFieldViewController ()<UIPopoverPresentationControllerDelegate>
- @end
- @implementation TextFieldViewController
- {
- IBOutlet UITextField *textField3;
- IBOutlet IQDropDownTextField *dropDownTextField;
- }
- #pragma mark - View lifecycle
- -(void)previousAction:(UITextField*)textField
- {
- NSLog(@"%@",NSStringFromSelector(_cmd));
- }
- -(void)nextAction:(UITextField*)textField
- {
- NSLog(@"%@",NSStringFromSelector(_cmd));
- }
- -(void)doneAction:(UITextField*)textField
- {
- NSLog(@"%@",NSStringFromSelector(_cmd));
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- [textField3 setCustomPreviousTarget:self action:@selector(previousAction:)];
- [textField3 setCustomNextTarget:self action:@selector(nextAction:)];
- [textField3 setCustomDoneTarget:self action:@selector(doneAction:)];
-
- dropDownTextField.keyboardDistanceFromTextField = 150;
-
- [dropDownTextField setItemList:@[@"Zero Line Of Code",
- @"No More UIScrollView",
- @"No More Subclasses",
- @"No More Manual Work",
- @"No More #imports",
- @"Device Orientation support",
- @"UITextField Category for Keyboard",
- @"Enable/Desable Keyboard Manager",
- @"Customize InputView support",
- @"IQTextView for placeholder support",
- @"Automanage keyboard toolbar",
- @"Can set keyboard and textFiled distance",
- @"Can resign on touching outside",
- @"Auto adjust textView's height ",
- @"Adopt tintColor from textField",
- @"Customize keyboardAppearance",
- @"play sound on next/prev/done"]];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
- if (self.presentingViewController)
- {
- [buttonPush setHidden:YES];
- [buttonPresent setTitle:@"Dismiss" forState:UIControlStateNormal];
- }
- }
- - (IBAction)presentClicked:(id)sender
- {
- @try {
- if (!self.presentingViewController)
- {
- TextFieldViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([TextFieldViewController class])];
- UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
- navigationController.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
-
- navigationController.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
-
- [navigationController setModalTransitionStyle:arc4random()%4];
-
- // TransitionStylePartialCurl can only be presented by FullScreen style.
- if (navigationController.modalTransitionStyle == UIModalTransitionStylePartialCurl)
- navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
- else
- navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
-
- [self presentViewController:navigationController animated:YES completion:nil];
- }
- else
- {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- }
- @catch (NSException *exception) {
- NSLog(@"Exception:%@",exception);
- }
- @finally {
-
- }
- }
- -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
- {
- if ([segue.identifier isEqualToString:@"SettingsNavigationController"])
- {
- segue.destinationViewController.modalPresentationStyle = UIModalPresentationPopover;
- segue.destinationViewController.popoverPresentationController.barButtonItem = sender;
-
- CGFloat heightWidth = MAX(CGRectGetWidth([[UIScreen mainScreen] bounds]), CGRectGetHeight([[UIScreen mainScreen] bounds]));
- segue.destinationViewController.preferredContentSize = CGSizeMake(heightWidth, heightWidth);
- segue.destinationViewController.popoverPresentationController.delegate = self;
- }
- }
- - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
- {
- return UIModalPresentationNone;
- }
- -(void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController
- {
- [self.view endEditing:YES];
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- {
- return YES;
- }
- - (BOOL)shouldAutorotate
- {
- return YES;
- }
- @end
|