NavigationBarViewController.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // NavigationBarViewController.m
  3. // IQKeyboard
  4. #import "NavigationBarViewController.h"
  5. #import "IQKeyboardReturnKeyHandler.h"
  6. #import "IQUIView+IQKeyboardToolbar.h"
  7. @interface NavigationBarViewController ()<UITextFieldDelegate,UIPopoverPresentationControllerDelegate>
  8. @end
  9. @implementation NavigationBarViewController
  10. {
  11. IQKeyboardReturnKeyHandler *returnKeyHandler;
  12. IBOutlet UITextField *textField2;
  13. IBOutlet UITextField *textField3;
  14. IBOutlet UIScrollView *scrollView;
  15. }
  16. -(void)dealloc
  17. {
  18. returnKeyHandler = nil;
  19. }
  20. - (void)viewDidLoad
  21. {
  22. [super viewDidLoad];
  23. textField3.placeholderText = @"This is the customised placeholder title for displaying as toolbar title";
  24. returnKeyHandler = [[IQKeyboardReturnKeyHandler alloc] initWithViewController:self];
  25. [returnKeyHandler setLastTextFieldReturnKeyType:UIReturnKeyDone];
  26. }
  27. -(void)viewWillAppear:(BOOL)animated
  28. {
  29. [super viewWillAppear:animated];
  30. }
  31. - (IBAction)enableScrollAction:(UISwitch *)sender {
  32. scrollView.scrollEnabled = sender.on;
  33. }
  34. - (IBAction)shouldHideTitle:(UISwitch *)sender
  35. {
  36. textField2.shouldHideTitle = !textField2.shouldHideTitle;
  37. }
  38. -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  39. {
  40. if ([segue.identifier isEqualToString:@"SettingsNavigationController"])
  41. {
  42. segue.destinationViewController.modalPresentationStyle = UIModalPresentationPopover;
  43. segue.destinationViewController.popoverPresentationController.barButtonItem = sender;
  44. CGFloat heightWidth = MAX(CGRectGetWidth([[UIScreen mainScreen] bounds]), CGRectGetHeight([[UIScreen mainScreen] bounds]));
  45. segue.destinationViewController.preferredContentSize = CGSizeMake(heightWidth, heightWidth);
  46. segue.destinationViewController.popoverPresentationController.delegate = self;
  47. }
  48. }
  49. - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
  50. {
  51. return UIModalPresentationNone;
  52. }
  53. -(void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController
  54. {
  55. [self.view endEditing:YES];
  56. }
  57. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  58. {
  59. return YES;
  60. }
  61. - (BOOL)shouldAutorotate
  62. {
  63. return YES;
  64. }
  65. - (IBAction)textFieldClicked:(UITextField *)sender
  66. {
  67. // [[[UIAlertView alloc] initWithTitle:@"Message" message:@"New Message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
  68. }
  69. @end