[英]How to scroll in a tableview programmatically
我在表視圖中有50行。 最初如何顯示10行,並在按鈕上單擊下一步10,依此類推?
在UITableView中使用scrollToRowAtIndexPath:atScrollPosition:animated
方法
聲明一個索引變量,當按下按鈕時,將其遞增10,使用該變量構造一個NSIndexPath
並調用上述方法。
例如:
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
您必須采用5個數組和一個主表數組。 在按鈕單擊方法中,您必須編寫
您應該將.h中的整數作為
。H
int number;
in viewDidLoad
{
number=0;
tableArray=array1;
}
-(IBAction)btnClk:(id)sender
{
number++;
if(number==5)
{
number=0;
}
if(number==0)
{
tableArray=array1;
}
if(number==1)
{
tableArray=array2;
}
if(number==2)
{
tableArray=array3;
}
if(number==3)
{
tableArray=array4;
}
if(number==4)
{
tableArray=array5;
}
[tableView reloadData];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.