UA-17470720-3

Jump to content


Photo
- - - - -

When editing, tableview not scrolling to make active first responder visible

view-controllers sections data-definitions

  • Please log in to reply
4 replies to this topic

#1 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 11 November 2015 - 12:30 PM

Was not sure which forum to put this in.

 

I'm using STV 5.1.3 (Checked the framework headers before posting), Xcode 7.1 (7B91b)

 

I'm making the table view models via code.  I have a Salesforce data class object, I'm making the class def and sections as below.  I'm manually generating the sections for one object with [TableViewModel generateSectionsForObject:withDefinition:]

 

For what it's worth, its in a detail view of at UISplitTableViewController.

 

Class definition:

- (void) configStudentInfo
{      
    SCClassDefinition *classDef = [SCClassDefinition definitionWithClass:[M2ClientStudentSObjectData class] propertyNamesString:@":(fieldClientExtID__c);Basics:(fieldFullName__c,fieldFirstName__c,fieldMiddleName__c,fieldLastName__c,fieldDOB__c,fieldGender__c)"];
    
    classDef.requireEditingModeToEditPropertyValues = YES;
    
    SCPropertyDefinition *studentIDDef = [classDef propertyDefinitionWithName:@"fieldClientExtID__c"];
    studentIDDef.title = @"Student ID";
    
    
    SCPropertyDefinition *fullNameDef = [classDef propertyDefinitionWithName:@"fieldFullName__c"];
    fullNameDef.title = @"Name";
    fullNameDef.existsInEditingMode = NO;
    fullNameDef.type = SCPropertyTypeLabel;
    fullNameDef.cellActions.didLayoutSubviews = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
    {
        SCLabelCell *labelCell = (SCLabelCell *)cell;
        labelCell.label.textAlignment = NSTextAlignmentLeft;
    };
    
    
    SCPropertyDefinition *firstNameDef = [classDef propertyDefinitionWithName:@"fieldFirstName__c"];
    firstNameDef.title = @"First";
    firstNameDef.existsInEditingMode = YES;
    firstNameDef.existsInNormalMode = NO;
    
    SCPropertyDefinition *middleNameDef = [classDef propertyDefinitionWithName:@"fieldMiddleName__c"];
    middleNameDef.title = @"Middle";
    middleNameDef.existsInEditingMode = YES;
    middleNameDef.existsInNormalMode = NO;
    
    SCPropertyDefinition *lastNameDef = [classDef propertyDefinitionWithName:@"fieldLastName__c"];
    lastNameDef.title = @"Last";
    lastNameDef.existsInEditingMode = YES;
    lastNameDef.existsInNormalMode = NO;
   
    
    SCPropertyDefinition *dobDef = [classDef propertyDefinitionWithName:@"fieldDOB__c"];
    dobDef.title = @"DOB";
    dobDef.existsInEditingMode = YES;
    dobDef.existsInNormalMode = YES;

    SCPropertyDefinition *genderDef = [classDef propertyDefinitionWithName:@"fieldGender__c"];
    genderDef.title = @"Gender";
    genderDef.existsInEditingMode = YES;
    genderDef.existsInNormalMode = YES;
    
    
    self.tableViewModel = [SCTableViewModel modelWithTableView:self.tableView];
    
    [self.tableViewModel generateSectionsForObject:self.studentObject withDefinition:classDef];
    
}

 

On both an iPad 3, and iPod Touch 6, in edit mode, DOB and Gender fields are under the keyboard. You can edit them fine, just can't see them.  Also can't scroll it up manually either.  Won't scroll high enough to get above the keyboard. Also, trying to scroll up closes the keyboard.

 

At this point, not sure how to debug it.  There's not much more code when whats above.  

 

Thanks

Seth

 

 



#2 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 11 November 2015 - 12:48 PM

Ok, so I added 

    self.tableViewModel.cellActions.didBecomeFirstResponder = ^(SCTableViewCell *cell,
                                                                NSIndexPath *indexPath) {
        NSLog(@"Cell at indexPath:%@ has become the first responder.", indexPath);
        [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
    };

 

It still won't scroll UNLESS I add additional fields below to make the tableView longer.  Then it will scroll to Gender, but not the  fields I added below that.  So the tableView/scrollview content insets aren't expanding to accommodate the keyboard (at least that the way I've done for keyboard management with non STV views)



#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 November 2015 - 01:09 PM

Hi Seth,

 

Is this an SCTableViewController or SCViewController? If it's an SCTableViewController, then the scrolling issues probably have very little to do with STV itself.



#4 Seth Vanderdrift

Seth Vanderdrift

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 108 posts
Reputation: 20
Excellent

Posted 11 November 2015 - 04:16 PM

Tarek,

 

Ok, I figured it out.  I'm presume it's documented, but I had some debug code in the SCTableViewController subclass, which used viewWillAppear: to log the object.

 

When I added the commented out [super viewWillAppear:animated], the scrolling started working as expected.

 

- (void) viewWillAppear:(BOOL)animated
{
//    [super viewWillAppear:animated];
    SCTableViewSection *firstSection = [self.tableViewModel sectionAtIndex:0];
    
    NSLog(@" -- DetailView %@", firstSection.boundObject);
    
}

 

So in general all the viewWill... viewDid....  methods should call super.(??)

 

Thanks,

Seth


  • Tarek likes this

#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 November 2015 - 05:28 PM

Yes of course, it's essential to the STV framework that these methods call super. 







Also tagged with one or more of these keywords: view-controllers, sections, data-definitions

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users