UA-17470720-3

Jump to content


Photo
- - - - -

TableView help


  • Please log in to reply
7 replies to this topic

#1 Ian Lawson-Smith

Ian Lawson-Smith

    Starting Out

  • STV 3.0 Std
  • Pip
  • 8 posts
Reputation: 1
Good

Posted 02 September 2011 - 01:18 PM

Hi,

I am trying to make a tableview list from core data which is working as expected.

My last cell on the first detail view is an imagepicker which I would like to be clickable to a new view to zoom in and out of the image unless the table is in edit mode which allows me to change image again.

From what I have found, there doesn't seem to be anything that does this.

Kind regards

Ian
  • hoinivoniough likes this

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 02 September 2011 - 01:55 PM

Hi Ian and welcome to our forums! :)

I am assuming you're using an SCArrayOfObjectsSection, right? By definition, an SCArrayOfObjectsSection will only display the cells corresponding to the objects that exist in it's 'items' array. To add an additional SCImagePickerCell to your table view, you should do that in a new additional section.

Please tell me if you need any additional help.

#3 Ian Lawson-Smith

Ian Lawson-Smith

    Starting Out

  • STV 3.0 Std
  • Pip
  • 8 posts
Reputation: 1
Good

Posted 02 September 2011 - 02:00 PM

Hi,

Thanks for the very quick reply.

I have a fabric class as follows.

@interface Fabric : NSManagedObject {
@private
}
@property (nonatomic, retain) NSString * colour;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * notes;
@property (nonatomic, retain) NSNumber * quantity;
@property (nonatomic, retain) NSNumber * status;
@property (nonatomic, retain) NSString * supplier;
@property (nonatomic, retain) NSString * image;

@end

I access this like the following.

tableViewModel = [[SCTableViewModel alloc] initWithTableView:[self tableView] withViewController:self];
	[tableViewModel setDelegate:self];
	
	// Make class def
	SCClassDefinition *fabricDef = [SCClassDefinition definitionWithEntityName:@"Fabric"
													  withManagedObjectContext:[delegate managedObjectContext]
															 withPropertyNames:[NSArray arrayWithObjects:@"name", @"quantity", @"supplier", @"colour", @"status", @"notes", @"image", nil]];
	
	[fabricDef setRequireEditingModeToEditPropertyValues:YES];
	
	// Customise the properties.
	SCPropertyDefinition *nameDef = [fabricDef propertyDefinitionWithName:@"name"];
	[nameDef setRequired:YES];
	[nameDef setAttributes:[SCTextFieldAttributes attributesWithPlaceholder:@"Name"]];
	
	SCPropertyDefinition *qtyDef = [fabricDef propertyDefinitionWithName:@"quantity"];
	[qtyDef setType:SCPropertyTypeNumericTextField];
	
	SCPropertyDefinition *notesPropertyDef = [fabricDef propertyDefinitionWithName:@"notes"];
	[notesPropertyDef setType:SCPropertyTypeTextView];
	
	SCPropertyDefinition *statusDef = [fabricDef propertyDefinitionWithName:@"status"];
	[statusDef setType:SCPropertyTypeSegmented];
	[statusDef setAttributes:[SCSegmentedAttributes attributesWithSegmentTitlesArray:[NSArray arrayWithObjects:@"Got It", @"Need It", nil]]];
	
	SCPropertyDefinition *imageDef = [fabricDef propertyDefinitionWithName:@"image"];
	[imageDef setType:SCPropertyTypeImagePicker];
	
	SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:@""
																	withEntityClassDefinition:fabricDef];
	
	[objectsSection setAddButtonItem:[[self navigationItem] rightBarButtonItem]];
	[objectsSection setAutoSelectNewItemCell:NO];

	[tableViewModel addSection:objectsSection];

I would like the last cell (Image cell) to take me to a different view if in edit mode or use the SCImagePicker when in edit mode.

Kind regards

James

#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 02 September 2011 - 03:25 PM

Hi James,

I now get what you're after. To have SCImagePickerCell have your required custom behavior, you need to subclass it and override its 'didSelectCell' method. Please tell me if you need any help with that.

#5 Ian Lawson-Smith

Ian Lawson-Smith

    Starting Out

  • STV 3.0 Std
  • Pip
  • 8 posts
Reputation: 1
Good

Posted 03 September 2011 - 10:02 AM

Hi Terekskr

That would be helpful thanks.

I am using Xcode 4.2 with ARC enabled so I don't need retains / releases.

I know how to subclass but I don't understand how I tell the PropertyDef to use the subclassed cell over the SCImagePickerCell.

Kind regards

James

#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 03 September 2011 - 10:15 AM

Hi James,

We'll be adding a detailed example of this in our next minor version release, due in less than 24 hours. The example will be added to our "Custom Cells App" sample application.

Please tell me if you need anything else.

#7 Ian Lawson-Smith

Ian Lawson-Smith

    Starting Out

  • STV 3.0 Std
  • Pip
  • 8 posts
Reputation: 1
Good

Posted 04 September 2011 - 02:48 PM

Hi Terekskr,

I have found by looking at the source that what I want is already implemented. All I have to do is configure the cell and set it enabled.

Thanks for all the help!

Kind regards

James

#8 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 04 September 2011 - 05:39 PM

Great, thanks for updating me on this.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users