KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm currently implementing automatic state preservation/restoration in an iOS6-only app. For a restoration of a table view, I added the UIDataSourceModelAssociation protocol to my table view controllers and implemented - (NSString *)modelIdentifierForElementAtIndexPath:(NSIndexPath *)idx inView:(UIView *)view and - (NSIndexPath *)indexPathForElementWithModelIdentifier:(NSString *)identifier inView:(UIView *)view When pressing the home button, the state preservation methods, including modelIdentifierForElementAtIndexPath:iView: , are getting called as expected and return valid identifier strings for the given index paths. When killing the app and relaunching it, state restoration works more or less. I.e. the app re-opens the correct table view. However, the table view is always scrolled to the top, even when it was scrolled to another position before. Here's the implementation of the UIDataSourceModelAssociation methods in my table view controller. Nothing fancy going on in there (the NdlFriend::accountUid property returns a unique identifier string for a given NdlFriend record): #pragma mark - UIDataSourceModelAssociation - (NSString *)modelIdentifierForElementAtIndexPath:(NSIndexPath *)idx inView:(UIView *)view { NSString* identifier = nil; NSArray* content = self.contentArray; // Sometimes idx might be nil... if(idx && idx.row<content.count) { NdlFriend* friend = content[idx.row]; identifier=friend.accountUid; } return identifier; } - (NSIndexPath *)indexPathForElementWithModelIdentifier:(NSString *)identifier inView:(UIView *)view { NSIndexPath * indexPath=nil; NSArray* content = self.contentArray; NSInteger count = content.count; for(NSInteger i=0;i<count;i++) { NdlFriend* friend = content[i]; if([identifier isEqualToSt
Tags (comma-separated)
Save Edits
Cancel