Welcome, Guest
Username Password: Remember me

Access to DetailView Control Properties
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Access to DetailView Control Properties

Access to DetailView Control Properties 1 year, 8 months ago #1

I am using an SCObjectSection with SCPropertyDefinitions to generate an input form. Is it is possible to access the properties of a control in a a given detailview? I am looking to modify a datepicker's minute interval.

[code]
// apptDate
SCPropertyDefinition *apptDatePropertyDef = [apptClassDef propertyDefinitionWithName:@"apptDate"];
apptDatePropertyDef.type = SCPropertyTypeDate;
apptDatePropertyDef.required = TRUE;
//apptDatePropertyDef.minuteInterval = 15; <-- would like to do set this property on date picker.
apptDatePropertyDef.title = @"Date";
[/code/

Thank you.
  • kes815
  • OFFLINE
  • Junior Boarder
  • Posts: 32
  • Karma: 0

Re: Access to DetailView Control Properties 1 year, 8 months ago #2

Sure. You can fully customize the auto generated cells of any class definition using two main methods:

1- All the really common customizations are provided through the attributes property of SCPropertyDefinition. Each property definition type has a corresponding attributes class. For example, a property definition of type SCPropertyTypeSelection should be assigned to attributes of type SCSelectionAttributes, which helps in defining the selection items in addition to how they're selected. In your case, setting an SCDateAttributes to your property definition does not cover what you want to customize, and thus you have two use the second method mentioned below.

2- Almost any other customization can be done using the SCTableViewCellDelegate methods willConfigureCell: and willDisplayCell:. For these delegate methods to get called, you need to set the automatically generated cells' delegate using your class definition's uiElementDelegate property. Here is some sample code that illustrates how to achieve what you want:

 
...
SCClassDefinition *apptClassDef = ...; // Create the class definition normally here
apptClassDef.uiElementDelegate = self;
// Your normal property definition here
SCPropertyDefinition *apptDatePropertyDef = [apptClassDef propertyDefinitionWithName:@"apptDate"];
apptDatePropertyDef.type = SCPropertyTypeDate;
apptDatePropertyDef.required = TRUE;
apptDatePropertyDef.title = @"Date";
...
 


Then implement the willConfigureCell: method

 
// Don't forget to conform to the SCTableViewCellDelegate protocol
// for this method to get fired
- (void)willConfigureCell:(SCTableViewCell *)cell
{
if([cell isKindOfClass:[SCDateCell class]])
{
[(SCDateCell *)cell datePicker].minuteInterval = 15;
}
}
 


Hope this helps
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Access to DetailView Control Properties 1 year, 8 months ago #3

Works perfectly - of course from my experience thus far I expected no less!

Given the time and frustration you have saved me I have to gush for a minute: During my 15 years in IT and Software Development I've learned you will deliver better and faster value by focusing on business solutions (in this case a compelling iPhone/iPad App) than by spending precious cycles wrapped up in "technology-for-the-sake-of-technology". I am new to iOS development and found myself getting wrapped up in the technology. At first it was fun, but then the fun turned to frustration. I realized I was not taking the "high value/low effort" route to my end game. Your product put me back on track. Thank you very much for what you have done for me and for other developers like me.
  • kes815
  • OFFLINE
  • Junior Boarder
  • Posts: 32
  • Karma: 0
  • Page:
  • 1
Time to create page: 1.46 seconds