-3

enter image description here

When the text field is empty and user tapped on the back button which action method will it call? My requirement is when the user tapped on the back button and text field is empty cursor will be on the previous text field.

Paulo Mattos
  • 18,845
  • 10
  • 77
  • 85
Vikash Dummy
  • 13
  • 1
  • 7

1 Answers1

-1

I think you need to add a custom back button and define its action.

 UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setFrame:CGRectMake(0,0,30,30)];
backButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

[backButton addTarget:self action:@selector(backBtnClicked:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *barBackButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];

navitem.hidesBackButton = YES;

navitem.leftBarButtonItems = @[barBackButtonItem];