Welcome, Guest
Username Password: Remember me

SCPropertyDefinition Required Autovalidate
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: SCPropertyDefinition Required Autovalidate

SCPropertyDefinition Required Autovalidate 1 year, 8 months ago #1

My application needs to make sure that the title of a row does not disappear, otherwise when the detail view naviagionController pushes a SCPropertyTypeSelection table, there is no title and hence no back button (stuck).

The code below allows me to edit my item and change myName to a blank string. How would I not allow the user to change myName to a blank string? I am binding to an array of objects.
<code>
SCPropertyDefinition *namePropertyDef = [shoeClassDef propertyDefinitionWithName:@"myName"];
namePropertyDef.type = SCPropertyTypeTextView;
namePropertyDef.title = @" ";
namePropertyDef.required = YES;
namePropertyDef.autoValidate = YES;

</code>
Thanks a lot
  • baberuth22
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 2

Re: SCPropertyDefinition Required Autovalidate 1 year, 8 months ago #2

Hi Bryan:

Is this an auto generated detail view? Auto generated detail views will automatically disable the save button if a required value is empty. If the detail view is not auto generated, all you need to do is set the enabled property of your save button to SCTableViewModel "valuesAreValid" property whenever any value changes.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: SCPropertyDefinition Required Autovalidate 1 year, 8 months ago #3

I don't have a save button.

Here is the code I am using:

- (void)tableViewModel:(SCTableViewModel *) tableViewModel detailViewWillAppearForRowAtIndexPath:(NSIndexPath *) indexPath withDetailTableViewModel:(SCTableViewModel *) detailTableViewModel
{
//Shoe *thisShoe = [tableData objectAtIndex:indexPath.row];
Shoe *thisShoe = [[shoeIndexedArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
 
 
SCTableViewSection *detailSection = [detailTableViewModel sectionAtIndex:0];
SCTableViewCell *imagePickerCell = [detailSection cellAtIndex:0];
imagePickerCell.imageView.image = [UIImage imageWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:[@"Documents/" stringByAppendingString:thisShoe.thumbName]]];
 
 
// Not working right now //////////////////////////
UINavigationBar *detailNavBar = detailTableViewModel.viewController.navigationController.navigationBar;
UINavigationItem *detailNavItem = detailTableViewModel.viewController.navigationController.navigationItem;
NSArray *statusItems = [[NSArray alloc] initWithObjects:@"Detail", @"Photo", nil];
UISegmentedControl *photoNavSegment = [[UISegmentedControl alloc] initWithItems:statusItems];
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
[myView addSubview:photoNavSegment];
//UIBarButtonItem *item = [[[UIBarButtonItem alloc] initWithCustomView:photoNavSegment] autorelease];
detailNavItem.titleView = myView;
// end ////////////////////
 
 
// Now add here any view you want to the navigation bar
 
//imagePickerCell.textLabel.frame = CGRectMake(60, 10, 200, 60);
//Shoe *myManagedObject = detailSection.boundObject;
//
// Set your managed object's attributes normally here
NSLog(@"IDetwail will appear at Index");
 
}
  • baberuth22
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 2

Re: SCPropertyDefinition Required Autovalidate 1 year, 8 months ago #4

To have Sensible TableView generate a modal detail view (thus enforcing validation and generating a save button for you), just set the "detailViewModal" property of SCArrayOfObjectsSection to TRUE. Please tell me if I understand your problem correctly.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: SCPropertyDefinition Required Autovalidate 1 year, 8 months ago #5

Excellent! Works perfectly
  • baberuth22
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 2
Last Edit: 1 year, 8 months ago by baberuth22.

Re: SCPropertyDefinition Required Autovalidate 1 year, 8 months ago #6

That works great for editing, but it does not work for my add item screen because I am not using an ArrayOfObjects section but only one SCObjectSection.


Here is my code that could work, but I have a modalViewController in progress from an imagePicker, so this code crashes:

UINavigationController *detailNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
[self presentModalViewController:detailNavController animated:TRUE];


Here is all of it.

 
- (void) loadNewObjectTable{
 
SCNavigationBarType navBarType;
if(self.navigationController)
navBarType = SCNavigationBarTypeNone;
else
navBarType = SCNavigationBarTypeDoneRightCancelLeft;
 
SCTableViewController *detailViewController = [[SCTableViewController alloc] initWithStyle:UITableViewStyleGrouped withNavigationBarType:navBarType];
detailViewController.delegate = self;
SCClassDefinition *shoeClassDef = [SCClassDefinition definitionWithClass:[Shoe class]
withPropertyNames:[mainDelegate attributeNamesArray]];
 
[self setupClassWithDefinition:shoeClassDef];
 
SCObjectSection *objSection = [SCObjectSection sectionWithHeaderTitle:nil withBoundObject:currentShoe withClassDefinition:shoeClassDef];
 
[detailViewController.tableViewModel addSection:objSection];
 
 
if(self.navigationController)
{
[self.navigationController pushViewController:detailViewController animated:TRUE];
}
else
{
 
// Create the navigation controller
UINavigationController *detailNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
[self presentModalViewController:detailNavController animated:TRUE];
}
 
 
[detailViewController release];
}
 
 
  • baberuth22
  • OFFLINE
  • Expert Boarder
  • Posts: 84
  • Karma: 2
Last Edit: 1 year, 8 months ago by baberuth22.
  • Page:
  • 1
  • 2
Time to create page: 2.68 seconds