Welcome, Guest
Username Password: Remember me

SCArrayOfObjectsModel Cell Definitions
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: SCArrayOfObjectsModel Cell Definitions

SCArrayOfObjectsModel Cell Definitions 1 year, 7 months ago #1

In my view controller I have an SCArrayOfObjectsModel tied to a core data entity. The entity has "caption", "dateAdded", and "imagePath."

In the core data model, "imagePath" is defined as an NSString like suggested. In the model, it is defined as an SCPropertyTypeImagePicker. After adding a new row in the tableView, the text of the row is showing the date (see screenshot).

Is there a way to tell the model what attribute to use here? What I'm really after is having the image that was selected in the ImagePicker to the left and the date or caption as the text (as opposed to showing the date only as it is now).

Is this possible at the moment? If not, is there a way I can get around it?

Thanks!

Screen_shot_2010_10_14_at_6.png
  • icyplains
  • OFFLINE
  • Expert Boarder
  • Posts: 133
  • Karma: 5
Last Edit: 1 year, 7 months ago by icyplains.

Re: SCArrayOfObjectsModel Cell Definitions 1 year, 7 months ago #2

I'm not sure if this the preferred/proper way, but this is how I was able to solve this:

 
 
- (void)tableViewModel:(SCTableViewModel *) tableViewModel willDisplayCell:(SCTableViewCell *) cell forRowAtIndexPath:(NSIndexPath *) indexPath
{
// Only if this is our main tableViewModel
if (tableViewModel.tag != 1)
{
SCArrayOfItemsModel *mod = (SCArrayOfItemsModel *) tableViewModel;
 
NSArray *items = mod.items;
 
NSString *fullName = [NSString stringWithFormat:@"Documents/%@", [[items objectAtIndex:indexPath.row] valueForKey:@"imagePath"]];
NSString *imgPath = [NSHomeDirectory() stringByAppendingPathComponent:fullName];
 
UIImage *img = [UIImage imageWithContentsOfFile:imgPath];
 
cell.imageView.image = img;
}
}
 
 
  • icyplains
  • OFFLINE
  • Expert Boarder
  • Posts: 133
  • Karma: 5

Re: SCArrayOfObjectsModel Cell Definitions 1 year, 7 months ago #3

Hi Tommy,

All you need is set the SCClassDefinition "titlePropertyName" property to the name of the attribute you want displayed in the SCArrayOfObjectsModel/SCArrayOfObjectsSection cells.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: SCArrayOfObjectsModel Cell Definitions 1 year, 7 months ago #4

That worked for "caption", but not for imagePath. Also, the title "Picture" as defined below doesn't show up either.


 
 
// Create a class definition for ProgressData
SCClassDefinition *progressDef = [SCClassDefinition definitionWithEntityName:@"ProgressData"
withManagedObjectContext:managedObjectContext_
withPropertyNames:[NSArray arrayWithObjects:@"imagePath", @"caption", @"addedDate", nil]];
progressDef.titlePropertyName = @"addedDate";
progressDef.descriptionPropertyName = @"addedDate";
 
 
SCPropertyDefinition *imagePropertyDef = [progressDef propertyDefinitionWithName:@"imagePath"];
imagePropertyDef.title = @"Picture";
imagePropertyDef.type = SCPropertyTypeImagePicker;
 
Screen_shot_2010_10_15_at_7.png
  • icyplains
  • OFFLINE
  • Expert Boarder
  • Posts: 133
  • Karma: 5
Last Edit: 1 year, 7 months ago by icyplains.

Re: SCArrayOfObjectsModel Cell Definitions 1 year, 7 months ago #5

Sorry I thought you were talking about the titles of the SCArrayOfObjectsModel, not SCImagePickerCell. The title of SCImagePickerCell is actually the image name, which is by default the time stamp that the image was selected at. To override this default, please implement the SCTableViewModelDelegate method called tableViewModel:newImageNameForRowAtIndexPath: (this will now work for newly selected images). If you don't want the image name to be displayed in the cell title at all, please set the displayImageNameAsCellText property to FALSE.

Hope I correctly understood your issue this time
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: SCArrayOfObjectsModel Cell Definitions 1 year, 7 months ago #6

I'm sorry, I probably confused you with the second screenshot- I also had a typo in the code in my post before this. There are 2 issues I'm having here

Let me try to clarify.

First:

I want the image that has been selected in the detailView to show up in the main tableView (SCArrayOfObjectsModel). I tried setting this "progressDef.titlePropertyName = @"imagePath";" (I had addedDate in there in the last post instead of imagePath).


Second:

In the detailView, I guess what I'm asking is is there a way to set a placeholder text to something like "Image" that can either stay there after you select the image or goes away and is replace by the image name. Either way would be fine.



I hope this makes more sense
  • icyplains
  • OFFLINE
  • Expert Boarder
  • Posts: 133
  • Karma: 5
  • Page:
  • 1
  • 2
Time to create page: 1.07 seconds