TableView Sections仅在iPhone5s和更高版本中覆盖

时间:2014-10-16 07:47:18

标签: ios objective-c uitableview

enter image description here我正在使用有两个部分的Grouped表,但它仅在iPhone 5s及更高版本中被覆盖。它在4s和5中运行良好。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    
    if (![[self.showingArray objectAtIndex:section]boolValue]) {
        return 1;
    }else{
        return [[self.sectionsArray objectAtIndex:section]count];;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"menuCell";
   // #warning : Use here your custom cell, instead of POPDCell
    POPDCell *cell = nil;
    cell = (POPDCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell) {
        cell=nil;
        [cell removeFromSuperview];
    }
    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"POPDCell" owner:self options:nil];
    if (cell == nil) {
        cell = [topLevelObjects objectAtIndex:0];
    }
}

这是5s屏幕截图中的输出

2 个答案:

答案 0 :(得分:1)

您需要编写以下代码。

-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

return HEIGHT;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return HEIGHT;
}

答案 1 :(得分:0)

 -(void)viewDidLoad
  {
 // ...
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(XXX, YYY, XXX, YYY)];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(XXX, YYY, XXX, YYY)];
    [headerView addSubview:imageView];
    UILabel *labelView = [[UILabel alloc] initWithFrame:CGRectMake(XXX, YYY, XXX, YYY)];
   [headerView addSubview:labelView];
    self.tableView.tableHeaderView = headerView;
    [imageView release];
   [labelView release];
   [headerView release];
 // ...
}