Welcome, Guest
Username Password: Remember me

Changing what is displayed in to Root View Controller
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Changing what is displayed in to Root View Controller

Changing what is displayed in to Root View Controller 1 year, 4 months ago #1

Morning

I am playing with the sample iPad App which is a great little App.

At the moment, the Root View Controller displays the name.

What I am trying to do is get it to display the category in the Root View Controller.

As I could not see where it was picking the name from, I decided to move the category up to the top, but now when you do an entry, it shows numbers, 0, 1 etc inteaded of the category name.

What am I missing ?

Iain
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0

Re: Changing what is displayed in to Root View Controller 1 year, 4 months ago #2

Hi Iain,

This is actually the correct behavior, as the category is being stored as an integer number representing the selection index. If you need to display the actual category name, you can easily do that in the willDisplayCell delegate method (like we did before). Please tell me if you need help with coding this.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Changing what is displayed in to Root View Controller 1 year, 4 months ago #3

Hi Tarek

Great - let me see if I can figure it out first.

Iain
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0

Re: Changing what is displayed in to Root View Controller 1 year, 4 months ago #4

Hi Tarek

I have been playing around with the code - it build ok but I dont get the categories listed because I have not got the right statements.

I have played around with the following:

- (void)tableViewModel:(SCTableViewModel *)tableViewModel
willDisplayCell:(SCSegmentedAttributes *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{


}



I am not sure if there should be something else below this code, so any help to point me in the right direction would be appreciated.

Iain
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0

Re: Changing what is displayed in to Root View Controller 1 year, 4 months ago #5

Hi Iain,

Your code should look something like this (don't forget to conform the the SCTableViewModelDelegate protocol in your header file):

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
willDisplayCell:(SCTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
SCArrayOfObjectsSection *tasksSection =
(SCArrayOfObjectsSection *)[tableViewModel sectionAtIndex:0];
 
// Get the corresponding task object
NSManagedObject *taskObject = [tasksSection.items objectAtIndex:indexPath.row];
 
// Get the selection index
int selectionIndex = [(NSNumber *)[taskObject valueForKey:@"category"] intValue];
 
// Now set the cell's text
switch (selectionIndex)
{
case 0:
cell.textLabel.text = @"Home";
break;
case 1:
cell.textLabel.text = @"Work";
break;
case 2:
cell.textLabel.text = @"Other";
break;
default:
cell.textLabel.text = @"No selection";
break;
}
}
 
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Changing what is displayed in to Root View Controller 1 year, 4 months ago #6

Hi Tarek

I added in the code, get no build errors etc, but I am still getting 0,1 and 2 in the listing.

Any ideas ?

Iain
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0
  • Page:
  • 1
  • 2
Time to create page: 1.73 seconds