Ios 在iPhone 4s的tableview中未获取搜索控件的正确位置
我使用Ios 在iPhone 4s的tableview中未获取搜索控件的正确位置,ios,uitableview,Ios,Uitableview,我使用CGPoint在tableview中使用indepath获取控件的位置。它与iphone5、iphone6和iphone6s配合良好,但与iphone4s配合不当。如果我错了,请提供解决方案 我正在使用以下代码: -(BOOL)searchBarShouldBeginEditing:(CustomSearchBar *)searchBar { CGRect cellRect =[self.tblFormDetail rectForSection:searchBar.indexPa
CGPoint
在tableview
中使用indepath
获取控件的位置。它与iphone5、iphone6和iphone6s配合良好,但与iphone4s配合不当。如果我错了,请提供解决方案
我正在使用以下代码:
-(BOOL)searchBarShouldBeginEditing:(CustomSearchBar *)searchBar
{
CGRect cellRect =[self.tblFormDetail rectForSection:searchBar.indexPath.section];
CGPoint origin=[self.tblFormDetail convertPoint:cellRect.origin fromView: self.tblFormDetail];
CGPoint originView=[self.view convertPoint:cellRect.origin fromView: self.tblFormDetail];
NSLog(@"origin from tbl %f",origin.y);
NSLog(@"origin from view %f",originView.y);
pointScroll=self.tblFormDetail.contentOffset;
pointSizeScroll=self.tblFormDetail.contentSize;
[self.tblFormDetail setContentSize:CGSizeMake(self.tblFormDetail.frame.size.width,pointSizeScroll.height+originView.y)];
[self.tblFormDetail setContentOffset:CGPointMake(0, origin.y)animated:NO];
}
Does
[searchBar convertPoint:CGPointZero-toView:self.tblFormDetail]代码>有什么不同吗?请解释您的视图层次结构,并解释您要转换的内容。我这样问是因为您的一些convertPoint
调用使用了相同的视图,因此不清楚您需要什么转换。不,我在tableview单元格中添加了搜索栏,当我单击此按钮时,我希望获得单击的点,以便显示另一个表中的选定记录。i表格不同控制器的数量感谢@Zhang您的解决方案正在运行。感谢所有的supportDoes[searchBar convertPoint:CGPointZero to View:self.tblFormDetail]代码>有什么不同吗?请解释您的视图层次结构,并解释您要转换的内容。我这样问是因为您的一些convertPoint
调用使用了相同的视图,因此不清楚您需要什么转换。不,我在tableview单元格中添加了搜索栏,当我单击此按钮时,我希望获得单击的点,以便显示另一个表中的选定记录。i表格不同控制器的数量谢谢@Zhang您的解决方案正在运行。感谢所有人的支持