1

NIB からストーリーボードに変換している古い iPhone アプリを継承しました。私が理解できないことの 1 つは、UITableView 内のセルの最初のページが背景色で覆われていることです。セルが作成され、入力されていることを確認しました。しかし、私はそれらを見ることができません。下にスクロールすると、下のセルがきれいに見えます。

TableView コード:

- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return segment_SECTION_HEIGHT;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return segment_CELL_HEIGHT;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSArray * allKeys = [segmentsByTimeDictionary allKeys];
    return allKeys.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSString *date = [timeSections objectAtIndex: section];
    NSMutableArray *timesegments = [segmentsByTimeDictionary objectForKey: date];

    return timesegments.count;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    NSString *date = [timeSections objectAtIndex: section];
    UIView *headerView = [[GradientView alloc] initWithStartColor: segment_SECTION_COLOR_TOP endColor: segment_SECTION_COLOR_BOTTOM];
    headerView.frame = CGRectMake(0, 0, tableView.frame.size.width, segment_SECTION_HEIGHT);
    UILabel *timeLabel = [[UILabel alloc] initWithFrame:
                          CGRectMake(10, 0, 320, segment_SECTION_HEIGHT)];
    timeLabel.backgroundColor = [UIColor clearColor];
    timeLabel.font = [UIFont boldSystemFontOfSize: 16];
    timeLabel.text = date;
    timeLabel.textColor = segment_SECTION_TEXT_COLOR;

    [headerView addSubview: timeLabel];

    return headerView;
//    return date;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"segmentCell";
    segmentCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
    NSDate *date = [timeSections objectAtIndex: indexPath.section];
    NSMutableArray *timesegments = [segmentsByTimeDictionary objectForKey: date];
    segments *segment = [timesegments objectAtIndex: indexPath.row];
    [cell setName: segment.name];

    return cell;
}

追加するために編集: viewDidLoad からこの関数呼び出しを削除すると、消えてしまうことに気付きました:

drawGradientBackground(self.view, DEFAULT_BACKGROUND_TOP, DEFAULT_BACKGROUND_BOTTOM);

その関数は次のように定義されます

CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.colors = [NSArray arrayWithObjects: (id) startColor.CGColor, (id) endColor.CGColor, nil];
gradient.frame = view.layer.bounds;

[view.layer insertSublayer: gradient atIndex: 0];

スクリーンショット: UITableView スクリーンショット

4

0 に答える 0