UA-17470720-3

Jump to content


Photo
- - - - -

how to use edit button's done, cancel event?

actions view-controllers models sections

  • Please log in to reply
4 replies to this topic

#1 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 03 April 2013 - 10:32 AM

hi ,

I would like to use the done, cancel button of the edit view. I am using the below code to create the detail view


[self.tableViewModel generateSectionsForObject:task withDefinition:taskdef];

======================

I tried all these methods but no luck

- (void)doneButtonAction

{

NSLog(@"edit done");


}

- (void)tableViewControllerDoneButtonTapped:(SCTableViewController *)tableViewController{


NSLog(@"edit done");

}



- (BOOL)tableViewModel:(SCTableViewModel *)tableViewModel shouldDismissDetailViewForRowAtIndexPath:(NSIndexPath *)indexPath withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel cancelButtonTapped:(BOOL)cancelTapped doneButtonTapped:(BOOL)doneTapped

{

NSLog(@"edit done");

return TRUE;

}


help me to use the edit button's done/cancel action


thanks,

bala


#2 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 541 posts
  • LocationIreland
Reputation: 134
Popular

Posted 04 April 2013 - 02:24 AM

Hi bala,

I assume that when you say you tried those methods but with no luck you mean the methods never get called.

To get delegate methods to fire for detail views you need to:

self.tableViewModel.autoAssignDelegateForDetailModels = YES;

Also, I've found that the tag of the root tableVIewModel is 0, the first detail is 1, the third is 2, so you can work out which detail view is firing the delegate.

I'm successfully using:

-(void)tableViewModelDidEndEditing:(SCTableViewModel *)tableViewModel

to know when Done (or Cancel) has been tapped in a detail view.

HTH

Edited by Dave Guerin, 04 April 2013 - 02:25 AM.

Cheers,

Dave

www.dgapps.ie

#3 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 04 April 2013 - 07:14 PM

hi Dave Guerin,

I tried your solution, but it dosent work anymore.

Kindly let me know if you have any idea on the same.

Thanks,
bala.

#4 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 541 posts
  • LocationIreland
Reputation: 134
Popular

Posted 04 April 2013 - 10:29 PM

Hi bala,

To get doneButtonAction to fire you need to be subclassing either SCTableViewController or SCViewController.

tableViewControllerDoneButtonTapped: doesn't seem to be a STV method, although there is a BOOL property doneButtonTapped.

tableViewModel:shouldDismissDetailViewForRowAtIndexPath:withDetailTableViewModel:cancelButtonTapped:doneButtonTapped is a SCTableViewModelDelegate so your class needs to declare it self as such a delegate for the method to be called.

Does any of that help?

When things aren't working the way I expect with STV I find it helpful to go back to one of the working examples and add in the bit I'm trying to get to work in my main project. Most times the slightly modified example works, and I can then see what I was doing wrong in my main project.
Cheers,

Dave

www.dgapps.ie

#5 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 07 April 2013 - 03:23 AM

Hi Dave,

Finally I ended up with following solution to get the action of edit mode's done, cancel buttons.


- (void)editingModeCancelButtonAction
{
// The cancel button has been tapped!

[super editingModeCancelButtonAction];

}
- (void)editButtonAction
{
if(self.tableView.editing)

{
NSLog(@"edit done");


// The Done button has been tapped!

}
[super editButtonAction];

}

Its working me fine.

Thank you dave.





Also tagged with one or more of these keywords: actions, view-controllers, models, sections

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users