監(jiān)聽tableVIew的偏移量
1、添加監(jiān)聽
[self.tableView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
2、監(jiān)聽的處理
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if ([keyPath isEqualToString:@"contentOffset"]){
CGPoint offset = [change[NSKeyValueChangeNewKey] CGPointValue];
}
}
3、移除監(jiān)聽
[self.tableView removeObserver:self forKeyPath:@"contentOffset" context:nil];
獲取子控件的Frame
1、section的frame
- (CGRect)rectForSection:(NSInteger)section;
說(shuō)明:包括了header、 footer和其所有cell
2、cell的frame
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath;
3、獲取header的frame
- (CGRect)rectForHeaderInSection:(NSInteger)section;
4、獲取footer的frame
- (CGRect)rectForFooterInSection:(NSInteger)section;