0
從Apple樣本「PageControl」中,我們可以知道UIPageControl可以用來控制滾動視圖中頁面的移動。可以使用UIPageControl來控制UITableView的移動嗎?
由於UITableView是UIScrollView的子類,我想使用UIPageControl來控制表視圖單元格的移動,就像在「PageControl」中一樣。
但是找不到代理的任何接口讓我這樣做。
的問題是:
這是可能做到這一點?爲什麼?
感謝
讓我回答我的問題有:
程控選擇和滾動
清單6-5編程選擇行
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath {
NSIndexPath *scrollIndexPath;
if (newIndexPath.row + 20 < [timeZoneNames count]) {
scrollIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row+20 inSection:newIndexPath.section];
} else {
scrollIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row-20 inSection:newIndexPath.section];
}
[theTableView selectRowAtIndexPath:scrollIndexPath animated:YES
scrollPosition:UITableViewScrollPositionMiddle];
}