Welcome, Guest
Username Password: Remember me

Change Navigation Bar Buttons in Detail Edit View
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Change Navigation Bar Buttons in Detail Edit View

Change Navigation Bar Buttons in Detail Edit View 1 year, 2 months ago #1

Hi All,

I have a question relating to changing the navigation bar buttons on a detail edit view. When a detail edit view is shown it has the standard SCNavigationBarTypeAddEditRight which consists of an Add and Edit button (nested within a SCTransparentToolbar) as the right hand button item in the navigation bar. So, at the moment the navigation bar consists of the back button on the left hand side followed by the Add and Edit buttons on the right hand side.

Would it be possible to only display the Edit button on the right hand side and, when the Edit button is tapped and the table enters edit mode, to disappear the back button and show the Add button in its place on the left (with fade animation of course)? Then, to go back the user would need to exit edit mode (by tapping the Done button now visible on the right) to hide the Add button and show the back button once again.

I know that I could change the navigationBarType to SCNavigationBarTypeEditRight but I have had two problems with this:

1. I don't know how to get a handle on the navigationBarType for a detail edit view. I have tried various ways within the tableViewModel:detailViewWillAppearForRowAtIndexPath:withDetailTableViewModel: method but can't seem to get access to that property.

2. Even if I can get the above working, how would I tell STV to show the Add button on the left hand side when in editing mode (and assign the correct behaviour to the Add button when tapped) and re-show the back button when not in editing mode?

Thanks for any help!
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: Change Navigation Bar Buttons in Detail Edit View 1 year, 2 months ago #2

Hey Matthew, nice to hear back again from you

What you're asking for is a big part of STV 2.1 new features! We're also planning to give you the ability to show/hide certain cells in edit mode, in addition to having the ability to change the actual type of the cell (e.g. from static SCLabelCell to an SCTextFieldCell). We now have the design ready and we should start implementing this as soon as STV 2.0 is released (we were actually planning to have this into STV 2.0 but couldn't due to time considerations).

How urgently do you need this Matthew?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Change Navigation Bar Buttons in Detail Edit View 1 year, 2 months ago #3

Hi Tarek,

Thanks for your reply. Also good to speak with you again

The functionality in STV 2.1 sounds fantastic. However, is there anything I can do to get the described navigation bar button changes in STV 2.0? I am almost ready to ship my app, and I would like to make this change so that the STV generated detail views are the same as some other (non-STV) table views in the app which have this different button configuration.

Although not totally desirable, if necessary I would be happy to make the necessary changes in the core STV files just to get me through until STV 2.1 is released.

Thanks again for your help!
Matthew
  • skoota
  • OFFLINE
  • Expert Boarder
  • Posts: 89
  • Karma: 2

Re: Change Navigation Bar Buttons in Detail Edit View 1 year, 2 months ago #4

Hi Matthew,

Sure, if all you need is change the navigation bar buttons (but not change the cell types for example), then you can fully do that manually. Generally speaking, you're always free to whatever you want with the navigation bar, since it's not at all part of STV. However, you should keep the following in mind if you are to override the automatically generated bar buttons in STV's detail views:

1- Replacing the Add&Edit buttons on the right with an Edit button is as simple as just setting the detailTableModel.viewController.navigationItem.rightBarButtonItem property.
2- You'll be totally responsible for handling what happens when the Edit button is tapped, like showing/hiding the Add button for example.
3- Please don't forget to tie your Add button to STV's SCArrayOfObjectsSection by assigning its "addButtonItem" property to the add button.

That's about it! Please tell me if you need further help.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Change Navigation Bar Buttons in Detail Edit View 1 year, 2 months ago #5

Hi Tarek,

Thanks (as always) for your prompt reply. Just regarding your instructions:

1- Replacing the Add&Edit buttons on the right with an Edit button is as simple as just setting the detailTableModel.viewController.navigationItem.rightBarButtonItem property.

3- Please don't forget to tie your Add button to STV's SCArrayOfObjectsSection by assigning its "addButtonItem" property to the add button.


These two I can do.

2- You'll be totally responsible for handling what happens when the Edit button is tapped, like showing/hiding the Add button for example.


When the Edit button is tapped I would like all the STV default behavior to happen, just with the added behavior that the Add button is shown or hidden. I know what code needs to be implemented to show/hide the Add button, but how would I go about telling the STV to enter and exit editing mode?

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

Re: Change Navigation Bar Buttons in Detail Edit View 1 year, 2 months ago #6

Hi Matthew,


how would I go about telling the STV to enter and exit editing mode?


Prior to STV 2.1, there is nothing special that you need to tell STV to do. Just call these two lines of code (you can ommit the first line if your view controller is a UITableViewController subclass)

 
[tableModel.viewController setEditing:editing animated:TRUE];
[tableModel.modeledTableView setEditing:editing animated:TRUE];
 


Good luck!
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 1.71 seconds