UA-17470720-3

Jump to content


Photo
- - - - -

Removing detail of deleted item


  • Please log in to reply
4 replies to this topic

#1 Karl1348790294

Karl1348790294

    Experienced Member

  • STV 5.0 Std
  • PipPipPipPip
  • 90 posts
Reputation: 6
Good

Posted 04 November 2015 - 11:57 PM

Hi,
I have master and detail in a split view.
When I delete a record from the master, then if that record was being currently displayed in the detail I want to dismiss the detail. So I am not displaying a deleted item.
How would be the best way to go about implementing this?
Thanks
Karl
  • Adjuramum likes this

#2 Karl1348790294

Karl1348790294

    Experienced Member

  • STV 5.0 Std
  • PipPipPipPip
  • 90 posts
Reputation: 6
Good

Posted 05 November 2015 - 02:07 AM

Alternatively, if i have a button on my detail item to delete to bound object.

How do i make sure that STV 'notices' the object is deleted and updates the master list in the right hands panel.

(This is my preferred alternative)

thanks

karl



#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 05 November 2015 - 05:34 AM

Hi Karl,

 

I am assuming here you're referring to the same app where you're custom presenting the view controller, because otherwise STV will automatically do this for you.

 

The following code snippet should do it for you:

 

        self.tableViewModel.sectionActions.didDeleteItem =
        {
            (itemsSection, indexPath) in
            
            let detailViewController = self.splitViewController!.viewControllers[1] as! SCTableViewController
            detailViewController.loseFocus()
        }

 

Hope this helps.


  • wizgod likes this

#4 Karl1348790294

Karl1348790294

    Experienced Member

  • STV 5.0 Std
  • PipPipPipPip
  • 90 posts
Reputation: 6
Good

Posted 05 November 2015 - 09:16 AM

Hi Tarek,

 

Thanks again for your help.

That code gets me part of the way there.

When I add this code the detail record is removed as hoped for, but it seems to interrupt the main list in the master pane, and the record does not get removed from the master list.

If i do not use that code, the record is removed from the master list, but not from the detail view.

thanks

karl


Edited by Karl1348790294, 05 November 2015 - 09:41 AM.


#5 Karl1348790294

Karl1348790294

    Experienced Member

  • STV 5.0 Std
  • PipPipPipPip
  • 90 posts
Reputation: 6
Good

Posted 05 November 2015 - 09:43 AM

Ok, well it did delete from the master view after all, but it seems to "come back" again when executing the loseFocus command.

I have however, sorted the problem, by using the .didDeleteItem action to push my logo view controller.

So this all seems ok now.

thanks again

karl






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users