UA-17470720-3

Jump to content


Photo
- - - - -

Link to new view controller (not STV)


  • Please log in to reply
6 replies to this topic

#1 sumowesley

sumowesley

    Sr. Member

  • STV 4.0 Std
  • PipPipPip
  • 33 posts
Reputation: 2
Good

Posted 07 May 2015 - 04:34 AM

I am in a detail view and I have added a UI button into the top most cell which is not bound to any data

 

If I link this button to the relevant view controller in IB for a "show" segue,  the new view controller is pushed onto the stack and appears nicely.

 

Of course, I want to be able to prepare an object on the new view controller (a subclassed Parse PFObject in my case) so i need to intercept that call. Not surprisingly, prepareForSegue is not called so I'm at a loss where I can intercept and assign my object on the new view controller to the one on the current detail view controller.

 

I'm like everyone else: the more I can do in IB, the better but where would I put the code I need to make the simple assignment?



#2 sumowesley

sumowesley

    Sr. Member

  • STV 4.0 Std
  • PipPipPip
  • 33 posts
Reputation: 2
Good

Posted 07 May 2015 - 08:10 AM

Found a way to get it to start to work.

1) Generate the detail section in IB

2) Subclassed SCTableViewController and change class of detail vc in IB

3) Implemented prepareForSegue

 

So how do I access the current object from my detail view controller?



#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 09 May 2015 - 06:29 AM

Hi sumowesley,

 

You can get the current object by accessing the button's parent cell as follows:

 

    UIView *parent = [myButton superview];
    while (parent && ![parent isKindOfClass:[SCTableViewCell class]]) 
    {
        parent = parent.superview;
    }

    SCTableViewCell *cell = (SCTableViewCell *)parent;
    NSObject *currentObject = cell.boundObject;

 

Hope this helps.



#4 sumowesley

sumowesley

    Sr. Member

  • STV 4.0 Std
  • PipPipPip
  • 33 posts
Reputation: 2
Good

Posted 10 May 2015 - 07:19 AM

Hi Tarek,

 

Thanks for that - I should be able to give it a try tonight.



#5 sumowesley

sumowesley

    Sr. Member

  • STV 4.0 Std
  • PipPipPip
  • 33 posts
Reputation: 2
Good

Posted 12 May 2015 - 03:23 AM

That works, thank you.

 

Does the SCTableViewController not have a bound Object if it is generated as a detail view?



#6 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 545 posts
  • LocationIreland
Reputation: 137
Popular

Posted 12 May 2015 - 06:45 AM

Hi sumowesley,

 

The SCTableViewControllers tableViewModel has a masterBoundObject which might be what you are looking for.

 

HTH


  • Tarek likes this
Cheers,

Dave

www.dgapps.ie

#7 sumowesley

sumowesley

    Sr. Member

  • STV 4.0 Std
  • PipPipPip
  • 33 posts
Reputation: 2
Good

Posted 12 May 2015 - 08:07 AM

That's the fella. Thank you.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users