• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Validation of fields in a navigation stack
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Validation of fields in a navigation stack


  • Subject: Re: Validation of fields in a navigation stack
  • From: Luther Baker <email@hidden>
  • Date: Thu, 09 Jan 2014 20:10:46 -0600

Create your own UIBarButtonItem button ... set it on the navigation item's leftBarButton property. Do what you want when they tap it with your own handler.

The left bar button will "cover" the back button.

> On Jan 9, 2014, at 6:22 PM, Rick Mann <email@hidden> wrote:
>
> What's the right way to validate fields in an editable detail view in a navigation stack? It seems that the API doesn't really provide a good means to do so without a lot of contortions, and so I wonder what the intended behavior is.
>
> Here's what I've got: A UINavigationController stack with a UITableView that shows a list of Jobs. You can add a new job, or select an existing job, and it pushes a new UITableViewController that is a detail view of the Job. Some of the fields in this detail view are editable (i.e. "Name").
>
> I don't want to allow the user to specify an empty name. So I had a separate "Save" button in the top-right of the nav bar, and I would validate everything in there before actually saving the changes to Core Data. I also had to subclass UINavigationController to prompt the user to discard changes if they tapped the back button (I also had to do this if they did something else to dismiss the UIPopover all this lives in).
>
> For other reasons, I'd like to change this behavior a bit to avoid the save step all together, and to always save any change. But I still need to validate that they don't try to save an empty name. I'm trying to do this with -[UITextFieldDelegate textFieldShouldEndEditing:], in which I present an alert and return NO if the field is empty. But that doesn't work if they tap the "back" button. In this case, I'm content with simply undoing whatever change they made and not saving the changes without prompting, but I have to be able to detect that that's what's happening. There is no UINavigationControllerDelegate method for popping a view controller, only showing a new one.
>
> I guess I could set a flag in -viewWillDisappear: indicating that the field is ending editing because the view is going away, and save or discard (without an alert) in that case.
>
> What are your thoughts?
>
> --
> Rick
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: CALayerGetSuperlayer called on instance of NSPathStore2
  • Next by Date: Re: Help to debug NSPerformService..
  • Previous by thread: Re: CALayerGetSuperlayer called on instance of NSPathStore2
  • Next by thread: Re: Validation of fields in a navigation stack
  • Index(es):
    • Date
    • Thread