UA-17470720-3

Jump to content


Photo
- - - - -

Table view displaying detail in master pane


  • Please log in to reply
14 replies to this topic

#1 Karl1348790294

Karl1348790294

    Experienced Member

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

Posted 28 July 2015 - 11:40 PM

Hi,

 

I have a very simple app based on the SC template with a master and detail view.

 

It all works fine out of the box, when the SCTableViewController is the root view for the master pane.

 

However, when I introduce a UIViewController (Inside the navigation controller) as the root of the master pane, which then pushes the SCTableViewController, the SCTableViewController seems to have lost the sense of being in the master pane, and now pushes all the detail records into the master pane on top of itself.

 

I am using STV 4 lite.

 

Any ideas what I have done wrong?

 

thanks

karl


Edited by Karl1348790294, 28 July 2015 - 11:40 PM.


#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 29 July 2015 - 06:33 AM

Hi Karl,

 

In the first scenario, STV was able to detect that it's the master controller in a UISplitViewController, and then automatically detect it's detail view controller based on that. Now that it's not the true master, you'll have to tell it about it's detail view controller since it can't figure that out on its own. The most convenient place to put that code is inside MasterViewController.m, and it should look something like this:

 

#import "AppDelegate.h"

@implementation MasterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UISplitViewController *splitViewController = (UISplitViewController *)[(AppDelegate *)[[UIApplication sharedApplication] delegate] window].rootViewController;
    SCTableViewController *detailViewController = (SCTableViewController *)[splitViewController.viewControllers lastObject];
    self.tableViewModel.detailViewController = detailViewController;
}

@end

 

Please let me know if this works for you.



#3 Karl1348790294

Karl1348790294

    Experienced Member

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

Posted 30 July 2015 - 12:44 AM

Thank you Tarek,

 

I have amended the code you suggest to the following Swift code:

 

        let myAppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
        let mySplitViewController = myAppDelegate.window!.rootViewController! as! UISplitViewController
      
        self.tableViewModel.detailViewController = mySplitViewController.viewControllers.last as! UINavigationController

 

(The detail view of the split view contains a navigation controller with a root view controller)

 

I now keep getting the message:

 

'Pushing a navigation controller is not supported'

 
When I select a record from the tableview
 
Many thanks for your help
 
Karl

Edited by Karl1348790294, 30 July 2015 - 12:55 AM.


#4 Karl1348790294

Karl1348790294

    Experienced Member

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

Posted 30 July 2015 - 01:16 AM

Ok, it looks like I have structured my storyboard incorrectly.

I think i have corrected it but now i get a an error:

 

'Storyboard (<UIStoryboard: 0x7febf0d3e260>) doesn't contain a view controller with identifier 'UIViewController-aly-VT-0lD'

 

When i try to create a new record.

I am not sure if this is something else i have introduced, or something that relates to STC.

 

thanks

 

karl



#5 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 30 July 2015 - 01:34 AM

u just have something in your storyboard that has been removed correctly when you changed things.. one of the properties still has a property that links or references UIViewController-aly-VT-0lD which isnt there


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#6 Karl1348790294

Karl1348790294

    Experienced Member

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

Posted 30 July 2015 - 01:51 AM

Ok, so I have tidied up my storyboard and got rid of the story reference.

 

I still have the error concerning pushing a navigation controller though.

 

thanks

karl



#7 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 30 July 2015 - 01:55 AM

im not a swift so i cant give you code

 

but you might want to read through the docset

 

detailViewController wants "The custom view controller. Must only be of type SCViewController or SCTableViewController."

 

not a navigation controller


Edited by ozie, 30 July 2015 - 01:55 AM.

  • Tarek likes this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#8 Karl1348790294

Karl1348790294

    Experienced Member

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

Posted 30 July 2015 - 02:45 AM

This code get rid of my error, but I am back where i started with the detail being pushed over the master view controller:


        let myAppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
        let mySplitViewController = myAppDelegate.window!.rootViewController! as! UISplitViewController
        let myDetailController = mySplitViewController.viewControllers.last?.rootViewController as? SCTableViewController

        self.tableViewModel.detailViewController = myDetailController


#9 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 30 July 2015 - 02:55 AM

set a break point on this line

let myDetailController = mySplitViewController.viewControllers.last?.rootViewController as? SCTableViewController

and lets see what myDetailController is.. is it the class of the view you want as the detail or is it nil ?


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#10 Karl1348790294

Karl1348790294

    Experienced Member

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

Posted 30 July 2015 - 03:17 AM

ok,... it's nil



#11 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 30 July 2015 - 03:30 AM

dont give up.. STV is great, but like anything in programming, its not 100% magic:)

 

If you upload your project, someone that likes swift might be able to help you more.. if it was objc i could :)


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#12 Karl1348790294

Karl1348790294

    Experienced Member

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

Posted 30 July 2015 - 04:25 AM

ok, will do

thanks

karl

 

Attached Files



#13 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 30 July 2015 - 08:41 AM

Hi Karl,

 

I've had a quick look at your project, and one thing I noticed is that you have a navigation controller before your detail view controller, which is great but my code did not account for that. You should update your code as follows:

 

let myAppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let mySplitViewController = myAppDelegate.window!.rootViewController! as! UISplitViewController
let detailNavController = mySplitViewController.viewControllers.last as! UINavigationController
      
self.tableViewModel.detailViewController = detailNavController.topViewController as! SCTableViewController

 

Hope this helps.



#14 Karl1348790294

Karl1348790294

    Experienced Member

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

Posted 30 July 2015 - 08:56 AM

Thank you Tarek,

I don't know quite what I was doing wrong, but that codes seems to have sorted my problem.

Many thanks!
Karl

#15 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 30 July 2015 - 09:17 AM

You're most welcome, Karl.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users