这是我的问题:
我有不同部分的uitableview,每个部分都有很多行。
问题是,当我在 iPad 模拟器中运行应用程序时,UITableView 中第 0 部分的前五行不会出现,除非我向上滚动查看它们,然后它们会在停止滚动后恢复不出现?
请帮忙 。在此先感谢并祝您编码愉快。
这是数据源方法的实现: 1。节数:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
NSMutableArray *catarr = [[NSMutableArray alloc] init];
catarr= [d Category];
NSInteger length ;
length = [catarr count];
return length;
}
2.行数:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
NSMutableArray *catarr = [[NSMutableArray alloc] init];
catarr = [d Category];
NSInteger length ;
length = [catarr count];
NSInteger count ;
NSMutableArray *word;
for ( int i=0 ; i < length ; i++)
{
if (section == i )
{
NSString *str = [catarr objectAtIndex:i];
word = [[NSMutableArray alloc] init];
word = [d CatRowName:str];
count = [word count];
return count;
}
}
return 0 ;
}
3. 索引路径处的单元格:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifer = @"Cell";
UITableViewCell *cell= [ tableView dequeueReusableCellWithIdentifier:CellIdentifer];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifer];
}
cell.textLabel.font = [UIFont systemFontOfSize:17.0];
UILabel *label ;
label=(UILabel *)[cell viewWithTag:1];
NSString *value = [[mainArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
label.text = value;
label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
label=(UILabel *)[cell viewWithTag:2];
NSString *value2 = [[mainArray2 objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
label.text= value2;
NSString *value3 = [[mainArray3 objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:value3];
label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
return cell;
}