[英]How to set cellForRowAtIndexPath method for 2 tableview in a storyboard
[英]How to Handle CellForRowAtIndexpath method
我有一个表视图,其中我在一个部分中有15行 。 所以当表视图加载时它只显示前9行 ,我用方法CellForRowAtIndexpath方法检查它,但是我希望在这个方法中为viewload方法调用所有15行。 请帮帮我。
提前致谢....
这取决于你设置的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
如果你有一个数组然后返回[arr count];
作为行数,如果你想要静态行,那么使用return 15;
在这种方法中
您可以使用这些方法,或者如果您希望所有单元格都在第一次查看前面,那么您应该使用最后一个方法减小单元格的高度。还要检查数组他有多少值。
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [Array count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier]
autorelease];
}
cell.textLabel.text=[Array objectAtIndex:indexPath.row];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 20;//use this method for cell height
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.