Welcome, Guest
Username Password: Remember me

Calling Nested TableViewController
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Calling Nested TableViewController

Calling Nested TableViewController 1 year, 7 months ago #1

Hi,

I've a requirement with 5 tab bar , one of the center tab bar button is mapped to the ViewControllerA. The ViewControllerA will display 3 table cells. Each Tabel Cell of ViewControllerA is mapped to ViewControllerA1,ViewControllerA2 & ViewControllerA3
Then ViewControllerA1 will have 30 tabel cells. Each tabel cell of ViewControllerA1 is mapped to detail view ViewControllerA11..

I'm trying to follow the sample project that has ObjectBindingVC sample. The object binding is good for the model class.How do I map view controller instead of model classes.How do I achieve the above nested VC requirement ?
Can you please help me? Anyone has sample code?

Thanks in Advance.
  • rajdn
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Karma: 0

Re: Calling Nested TableViewController 1 year, 7 months ago #2

Hi Raj,

The easiest way to achieve this is by using an SCArrayOfStringsSection or SCArrayOfStringsModel (if you need automatically generated sections) in each of your view controllers. Then, you will need to set the "allowEditDetailView" property to FALSE and provide your own detail view by overriding the SCTableViewModelDelegate method called tableViewModel:didSelectRowAtIndexPath:. Here is some code sample:

 
// ViewControllerA.m
- (void)viewDidLoad {
..
NSArray *cellTitles = [NSArray arrayWithObjects:@"Title 1", @"Title 2", @"Title 3", nil];
SCArrayOfStringsSection *section = [SCArrayOfStringsSection sectionWithHeaderTitle:nil
withItems:cellTitles];
section.allowEditDetailView = FALSE;
[tableModel addSection:section];
..
}
 
..
 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch(indexPath.row)
{
case 1: //Display ViewControllerA1; break;
case 2: //Display ViewControllerA2; break;
case 3: //Display ViewControllerA3; break;
}
}
 


You may also want to watch this video tutorial to see this in action.

Hope this helps.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
Last Edit: 1 year, 7 months ago by tarekskr.

Re: Calling Nested TableViewController 1 year, 7 months ago #3

Thanks for you'r help..I'm in love with this product now.. I can do more stuff.. One more question.
I wanted to display each VC under sperate sections. When user clicks the view controller VC1 under section1 display view controller VC1 and if user clicks the view controller VC2 under section2 display view controller VC2. I tried with below code
but it always goes to VC1. How do I tell the section 2 needs to display VC2 instead of VC1? Also my cell does'nt have arrow indication.Anything needs to setup arrow indication..


- (void)tableViewModel:(SCTableViewModel *)tableViewModel
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DDLogInfo(@" didSelectRowAtIndexPath ......");
UIViewController *viewController;
switch (indexPath.row) {
case 1:
viewController = [[ViewController1 alloc] initWithNibName:@"ViewController1" bundle:nil] autorelease];
break;
case 2:
viewController = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil] autorelease];
break;
case 3:
viewController = [[ViewController3 alloc] initWithNibName:@"ViewController3" bundle:nil] autorelease];
break;
default:
viewController = [[UIViewController alloc] init] autorelease];
}

[self.navigationController pushViewController:viewController animated:YES];
}


sctv.jpg
  • rajdn
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Karma: 0
Last Edit: 1 year, 7 months ago by rajdn. Reason: added img

Re: Calling Nested TableViewController 1 year, 7 months ago #4

You're welcome Raj

1. Regarding your VC for each section question, I am asuming you only have one cell per section right? If that's true, then all you have to do is replace switch(indexPath.row) in your code with switch(indexPath.section).

2. Regarding the disclosure indicator disappearing when you set allowEditDetailView to FALSE, I'll now send you an update that fixes this issue.

Thanks!
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Calling Nested TableViewController 1 year, 7 months ago #5

Great. Another question regarding Navigation bar title. The previous selected title is missing in the detail view
svt.jpg
  • rajdn
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Karma: 0

Re: Calling Nested TableViewController 1 year, 7 months ago #6

I don't quite get what you mean Raj. Would you please explain more? Thanks!
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 1.01 seconds