我想设置一个tableView 的 contentInsets
属性一直为 0,这是我的代码:
class_replaceMethod([UITableView class], @selector(setContentInset:), (IMP)setContentInsetZero, "@");
setContentInsetZero
函数 :
void setContentInsetZero(id SELF, SEL _cmd, UIEdgeInsets insets) {
Ivar tableViewInsets = class_getInstanceVariable([UITableView class], "_contentInset");
object_setIvar(SELF, tableViewInsets, [NSValue valueWithUIEdgeInsets:UIEdgeInsetsZero]);
}
会走这个函数,但是并没有什么卵用…… 求大神解惑
淡淡烟草味2017-04-28 09:08:09
class_replaceMethod([UITableView class], @selector(setContentInset:), (IMP)setContentInsetZero, "@");
Why do we need to pass "@" in the third parameter? It should be passed:
method_getTypeEncoding(class_getInstanceMethod([UITableView class], @selector(setContentInset:)))