我是iOS新手,面臨着自動滾動表格視圖單元格的問題。 我使用這樣的代碼如何自動滾動目標中的自定義表格視圖單元格C
- (void)viewDidAppear:(BOOL)animated{
[table setContentOffset:CGPointMake(0.0, table.contentSize.height - table.bounds.size.height)
animated:YES];
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[headarray count]-1 inSection:0]
atScrollPosition:UITableViewScrollPositionBottom
animated:YES];
}
但它讓我壞訪問什麼,我提前做錯了這個code.Thanks!
我試試你這樣的代碼在connectionDidFinishLoading方法
if ([headarray count] != 0) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[headarray count]-1 inSection:0];
[Newstable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
你的代碼是完全正確的,但檢查了這'[musicGenre數] -1切入口:0]',它是什麼返回,檢查它的價值和等級。 –
@muja嘗試我的代碼,只是刪除你的[表setContentOffset:CGPointMake(0.0,table.contentSize.height - table.bounds.size.height) animated:YES];這條線 –
@Muju你想在最後一排桌子上滾動嗎? –