//當tableView的cell數(shù)量改變后再次reload盖淡,contentOffset的值是通過預估各cell的高度及header趣苏、footer的高度后計算得到的狡相,并非準確的值;所以需要關(guān)閉它食磕。
1. ? ?self.tableView.estimatedRowHeight = 0;
? ? self.tableView.estimatedSectionHeaderHeight = 0;
? ? self.tableView.estimatedSectionFooterHeight = 0;
2. -(void)tableView:(UITableView*)tableViewdidSelectRowAtIndexPath:(NSIndexPath*)indexPath{
? ? //點擊cell獲取屏幕坐標
? ? CGRectrectInTableView = [tableViewrectForRowAtIndexPath:indexPath];
? ? CGRectrect = [tableViewconvertRect:rectInTableViewtoView:[tableViewsuperview]];
? ? NSLog(@"%f%f",rect.origin.x,rect.origin.y);
? ? NSString*selectRowStr = [NSStringstringWithFormat:@"%ld",indexPath.row];
? ? NSLog(@"選擇了第%@行",selectRowStr);
? ? if(_selectRowAry.count!=0) {
? ? ? ? NSString* row = [_selectRowAry objectAtIndex:0];?
[_selectRowAry removeAllObjects];
? ? ? ? if([rowisEqualToString:selectRowStr]) {
? ? ? ? ? ? self.detailsView.hidden=YES;
? ? ? ? }else{
? ? ? ? ? ? [_selectRowAryaddObject:selectRowStr];
? ? ? ? ? ? self.detailsView.hidden=NO;
?? ? ? ? ? ? CGFloatheigth = (rect.origin.y-27+DETAILSHEIGHT) - (self.view.bounds.size.height-55);
? ? ? ? ? ? if(heigth >0) {
? ? ? ? ? ? ? ? ? self.detailsView.frame=CGRectMake(ScreenWidth-DETAILSWIDTH-92, indexPath.row*55-heigth,DETAILSWIDTH,DETAILSHEIGHT);
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? self.detailsView.frame = CGRectMake(ScreenWidth-DETAILSWIDTH-92, indexPath.row *55+27, DETAILSWIDTH, DETAILSHEIGHT);
? ? ? ? ? ? }
? ? ? ? }
? ? }else{
? ? ? ? [_selectRowAryaddObject:selectRowStr];
?? ? ? ? ? ? ? ? ? self.detailsView.hidden=NO;
? ? ? ? CGFloatheigth = (rect.origin.y-27+DETAILSHEIGHT) - (self.view.bounds.size.height-55);
? ? ? ? if(heigth >0) {
? ? ? ? ? ? ? self.detailsView.frame=CGRectMake(ScreenWidth-DETAILSWIDTH-92, indexPath.row*55-heigth,DETAILSWIDTH,DETAILSHEIGHT);
? ? ? ? }else{
? ? ? ? ? ? ? self.detailsView.frame = CGRectMake(ScreenWidth-DETAILSWIDTH-92, indexPath.row *55+27, DETAILSWIDTH, DETAILSHEIGHT);
? ? ? ? }
? ? }
}