Welcome, Guest
Username Password: Remember me

Validation of detail edit view controller
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Validation of detail edit view controller

Validation of detail edit view controller 1 year, 4 months ago #1

Hi All,

I have an STV with a fairly standard setup bound to Core Data. When a user creates a new row in the STV a modal window appears allowing all of the attributes to be completed. If there are mandatory attributes the Done button will not activate until the mandatory fields have been completed.

However, if the user then taps on a row in the table view, and the detail edit view controller gets pushed onto the navigation stack, they are able to submit the changes (by pressing the Back button) even if the mandatory fields have not been completed (resulting in the program crashing due to the Core Data mandatory field requirements not being met). I understand that I can present the detail edit view modally so that the Done button will not activate unless everything is correctly completed, but a modal edit detail view is not an option for my app. Is there a way to achieve similar validation when the detail view is pushed onto a navigation controller (e.g. removing the back button if the mandatory fields have not been completed)?

Thanks,
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: Validation of detail edit view controller 1 year, 4 months ago #2

Hi Matthew,

To consistently enforce validation rules, STV 2.0 by default now always displays the Cancel/Done buttons in any detail view (not just modal detail views). STV 2.0 release date has been postponed to the end of this month, but I can give you an RC in the next couple of days if you're in a hurry.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Validation of detail edit view controller 1 year, 4 months ago #3

Hi Tarek,

Thanks for your message. That sounds like a good way to address the issue. If you could send through the RC when it's available that would be perfect.

Thanks,
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: Validation of detail edit view controller 1 year, 4 months ago #4

Hi Tarek,

Thanks for sending through STV 2.0 RC1 which addresses the comments in this thread. A quick suggestion - to keep the consistency of established UI metaphors, when the view controller is pushed onto a navigation stack would it be possible to display the standard UINavigationController Back button instead of a Cancel button? I think that would look more consistent in this situation and reinforce that the view controller has been pushed rather than displayed modally. The user would then tap the Back button to cancel the changes, or tap the Done button to save the changes. What do you think?

Others may have differing opinions so feel free to comment. The ultimate would be if you could make a Boolean property which allows the developer to choose using a Back button or Cancel button for their particular use-case.

Of course, all the above only applies if the user has pushed the view controller onto a navigation stack - the Cancel button should obviously always be used if the view controller is displayed modally.

Thanks,
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: Validation of detail edit view controller 1 year, 3 months ago #5

Hi Matthew,

Earlier on during development, we've actually thought a lot about what you're suggesting (even the boolean property for back or cancel), and we decided against it for the following reasons:

- In most apps (including Apple's, e.g.: Settings), the back button is not used to cancel the user's input, but it's rather used to commit it. Users can very easily miss the Done button and by habit just tap the back button, only to discover that all their modifications have all been canceled. Not a good thing

- What we finally choose to do comes right out of one of Apple's own applications: the Calendar app. If you go to the Calendar, select an existing event, then tap Edit. Now if you tap the Title/Location for example, a detail view is pushed into the stack with a Cancel & Done buttons, and with no back button. Thus, this confirmed to us that this is the right way to do it.

Having said that, I am now thinking that it might be better to just change the title of the back button to "Cancel", instead of completely replacing it. Please tell me what you think.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Validation of detail edit view controller 1 year, 3 months ago #6

Hi Tarek,

Thanks for your message. I tried looking very hard for an Apple app which used validation when pushing a detail view onto a navigation stack (to see how they handled it) but could not find one, so your suggestion of looking in the Calendar app was fantastic. I can see what you mean about the use of the Done and Cancel buttons in this scenario. It's interesting though that this is not used very heavily at all across other apps, presumably because it somewhat breaks the nice visual cue of the back button indicating that the view controller is on a navigation stack.

I like your suggestion of changing the title of the back button to "Cancel" but even this breaks the visual cue to a small degree. I am thinking there isn't going to be a great way around this issue, so perhaps it would be good to provide the developer with a selection of options and they can implement the most suitable for their use-case. My suggestions would be having the following options:
  • Cancel and Done button (i.e. as at the moment in STV 2.0 RC1)
  • Normal back button and Done button
  • "Cancel" back button and Done button
  • Normal back button only (i.e. as with the current stable version of STV) but the back button disappears with animation when the mandatory field requirements have not been met and reappears when they have been met
For my implementation I would be very interested to experiment with the fourth option (i.e. normal back button disappears with animation) to see if it would work well, as I have already implemented code which will highlight a mandatory incomplete field, giving the user feedback about what is the problem.

What do you think?

Thanks,
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2
  • Page:
  • 1
  • 2
Time to create page: 1.69 seconds