我必须实现UIDataSourceModelAssociation吗?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我必须实现UIDataSourceModelAssociation吗?相关的知识,希望对你有一定的参考价值。
在我的应用中,我的UIViewController状态恢复工作得很好,我的所有UITableView实例都设置了restorationIdentifier。一切都按预期工作,我甚至可以在状态恢复数据文件中看到我的UITableViews的contentOffset。
但当我重新启动我的应用程序时,我所有的表视图都会重置它们的滚动位置。我必须实现UIDataSourceModelAssociation协议才能获得这个功能吗?我的数据源是相当静态的,所以这样做是相当多余的。
答案
是的 UITableView
中的方法。UIDataSourceModelAssociation
其间 encodeRestorableState
以获取屏幕顶部单元格中的项目标识符,并将其写入键。kTopApplicationTopVisibleModelIdentifier
然后在还原时,它会询问该项目索引路径并滚动到它。它还使用它来恢复版本状态和选定的行。
/* @class UITableView */
-(void)encodeRestorableStateWithCoder:(void *)arg2 {
r13 = [arg2 retain];
rax = [self dataSource];
rax = [rax retain];
var_C0 = [objc_opt_class(rax) conformsToProtocol:@protocol(UIDataSourceModelAssociation)];
[rax release];
var_160 = self;
*(&var_160 + 0x8) = *_OBJC_CLASSLIST_SUP_REFS_$_.153;
[[&var_160 super] encodeRestorableStateWithCoder:r13];
var_B8 = self;
rax = [self window];
rax = [rax retain];
r14 = [[rax firstResponder] retain];
[rax release];
if (((objc_opt_isKindOfClass(r14, objc_opt_class(@class(UIView))) & 0x1) != 0x0) && ([r14 isDescendantOfView:var_B8] != 0x0)) {
rcx = @"UIViewNeedsLayoutKey";
[r13 encodeBool:0x1 forKey:rcx];
}
if (var_C0 != 0x0) {
var_C8 = r14;
[var_B8 contentOffset];
var_E0 = intrinsic_movsd(var_E0, xmm0);
var_D8 = intrinsic_movsd(var_D8, xmm1);
[&var_180 _contentInset];
intrinsic_addsd(intrinsic_movsd(xmm1, var_D8), var_180);
intrinsic_movsd(xmm0, var_E0);
rax = [var_B8 _indexPathForRowAtPoint:0x1 usingPresentationValues:rcx];
rax = [rax retain];
r14 = rax;
if (rax != 0x0) {
rax = [var_B8 _dataSourceProxy];
rax = [rax retain];
rcx = var_B8;
r15 = [[rax modelIdentifierForElementAtIndexPath:r14 inView:rcx, r8] retain];
[rax release];
if (r15 != 0x0) {
rcx = @"kTopApplicationTopVisibleModelIdentifier";
[r13 encodeObject:r15 forKey:rcx];
}
[r15 release];
}
[r14 release];
r14 = var_C8;
}
if ([var_B8 isEditing] != 0x0) {
rax = @(YES);
rax = [rax retain];
rcx = @"kApplicationIsEditingKey";
[r13 encodeObject:rax forKey:rcx];
[rax release];
}
rdx = 0x1;
rax = [var_B8 _indexPathsForSelectedRowsUsingPresentationValues:rdx, rcx];
rax = [rax retain];
rbx = rax;
rsi = @selector(count);
if (_objc_msgSend_1426728(rax, rsi, rdx, rcx) != 0x0) {
rsi = @selector(encodeObject:forKey:);
rcx = @"kApplicationSelectedCellIndexPathsKey";
rdx = rbx;
(*_objc_msgSend)(r13, rsi);
if (var_C0 != 0x0) {
var_C8 = r14;
var_F8 = r13;
var_E8 = [[NSMutableArray array] retain];
var_150 = intrinsic_movaps(var_150, 0x0);
*(int128_t *)(&var_150 + 0x10) = intrinsic_movaps(*(int128_t *)(&var_150 + 0x10), 0x0);
*(int128_t *)(&var_150 + 0x20) = intrinsic_movaps(*(int128_t *)(&var_150 + 0x20), 0x0);
*(int128_t *)(&var_150 + 0x30) = intrinsic_movaps(*(int128_t *)(&var_150 + 0x30), 0x0);
var_F0 = rbx;
rax = [rbx retain];
rcx = &var_B0;
var_D0 = rax;
rdx = &var_150;
rax = [rax countByEnumeratingWithState:rdx objects:rcx count:0x10];
var_C0 = rax;
if (rax != 0x0) {
var_108 = **(&var_150 + 0x10);
r12 = var_B8;
do {
r14 = 0x0;
do {
if (*var_140 != var_108) {
objc_enumerationMutation(var_D0);
}
rbx = *(var_148 + r14 * 0x8);
rax = [r12 _dataSourceProxy];
rax = [rax retain];
rsi = @selector(modelIdentifierForElementAtIndexPath:inView:);
rdx = rbx;
rcx = r12;
rbx = [_objc_msgSend_1426728(rax, rsi) retain];
[rax release];
if (rbx != 0x0) {
rsi = @selector(addObject:);
rdx = rbx;
_objc_msgSend_1426728(var_E8, rsi, rdx, rcx);
}
[rbx release];
r14 = r14 + 0x1;
} while (r14 < var_C0);
rdx = &var_150;
rcx = &var_B0;
rax = [var_D0 countByEnumeratingWithState:rdx objects:rcx count:0x10];
var_C0 = rax;
} while (rax != 0x0);
}
[var_D0 release];
rbx = var_E8;
rsi = @selector(count);
r13 = var_F8;
if ((*_objc_msgSend)(rbx, rsi) != 0x0) {
rcx = @"kApplicationSelectedCells";
rsi = @selector(encodeObject:forKey:);
rdx = rbx;
(*_objc_msgSend)(r13, rsi);
}
[rbx release];
r14 = var_C8;
rbx = var_F0;
}
}
var_30 = **___stack_chk_guard;
[rbx release];
[r14 release];
[r13 release];
if (**___stack_chk_guard != var_30) {
__stack_chk_fail();
}
return;
}
反编译 漏斗
以上是关于我必须实现UIDataSourceModelAssociation吗?的主要内容,如果未能解决你的问题,请参考以下文章
我必须实现哪个 SPL 接口才能在对象上使用 usort() 函数?
laravel : count(): 参数必须是数组或实现 Countable 的对象