Welcome, Guest
Username Password: Remember me

How do i realize a table view with presentation view and edit view
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: How do i realize a table view with presentation view and edit view

How do i realize a table view with presentation view and edit view 1 year, 5 months ago #1

Hi,

Is it possible to show a detail view of an object with non-editable
table view cells, but with a button to jump to the editable table view.

I know that is possible to realize this manually, but i want to use the
SCClassDefinition. There is no example for this szenario.
  • gemuese
  • OFFLINE
  • Senior Boarder
  • Posts: 52
  • Karma: 2

Re: How do i realize a table view with presentation view and edit view 1 year, 5 months ago #2

Hi Julian,

Thanks a lot for the interesting question. The way I'd approach this is that I'd create everything normally, then when the button is tapped, I'd loop through all the cells in the section and set their control's "enabled" property to FALSE. Here is a code sample illustrating this:

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
detailViewWillAppearForRowAtIndexPath:(NSIndexPath *)indexPath
withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel
{
// objectSection is just a variable to hold the object section
self.objectSection = [detailTableViewModel sectionAtIndex:0];
 
[self setEnabledStateForSection:self.objectSection state:FALSE];
 
// You can add the toggle button to the detail navigation bar here
UIBarButtonItem *button = [[UIBarButtonItem alloc]
initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:self
action:@selector(buttonTapped)];
 
detailTableViewModel.viewController.navigationItem.rightBarButtonItem = button;
 
[button release];
}
 
- (void)buttonTapped
{
// controlState is just a variable used to toggle the control states
self.controlState = !self.controlState;
 
[self setEnabledStateForSection:self.objectSection
state:self.controlState];
}
 
- (void)setEnabledStateForSection:(SCTableViewSection *)section
state:(BOOL)state
{
for(int i=0; i<section.cellCount; i++)
{
SCTableViewCell *cell = [section cellAtIndex:i];
if([cell isKindOfClass:[SCControlCell class]])
{
SCControlCell *controlCell = (SCControlCell *)cell;
if([controlCell.control isKindOfClass:[UIControl class]])
{
((UIControl *)controlCell.control).enabled = state;
}
else if([controlCell.control isKindOfClass:[UITextView class]])
{
((UITextView *)controlCell.control).editable = state;
}
}
}
}
 
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
  • Page:
  • 1
Time to create page: 0.77 seconds