我在UITableViewCell中有一個按鈕,它存儲爲稱爲currentButton的ivar。單擊該按鈕時,將調用包含UIPickerView和UIToolBar的UIView,並從屏幕底部顯示該UIView。然而,我已經看了幾個小時的其他職位,下面的代碼仍然不起作用。單元格有時在鍵盤下方向下滾動,並且UITableView底部的單元格不會向上滾動到UIView backgroundPickerView頂部。這是我的代碼:滾動UITableViewCell到可見不按預期工作
CGPoint center = currentButton.center;
CGPoint rootViewPoint = [currentButton.superview convertPoint:center toView:self.view];
NSIndexPath *indexPath = [measurementTableView indexPathForRowAtPoint:rootViewPoint];
CGRect cellRect = [measurementTableView rectForRowAtIndexPath:indexPath];
if (cellRect.origin.y + cellRect.size.height >= backgroundPickerView.frame.origin.y) {
[measurementTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
CGPoint offset = measurementTableView.contentOffset;
offset.y += ((cellRect.origin.y - cellRect.size.height) - backgroundPickerView.frame.origin.y);
[measurementTableView setContentOffset:offset animated:YES];
}
有沒有人看到我在做什麼錯在這裏?
是self.view和measurementTableView相同的視圖嗎? – wj2061
@ wj2061不,self.view持有measurementTableView –
您是否找到任何解決方案? –