相关疑难解决方法(0)

UITableView单元格带有背景图片

我有一个UITableView,其中有3个图像.1表示所选单元格,1表示单元格背景,1表示TableView背景.

我选择的Cell,工作正常,但是正常单元格和TableView背景(当你向下滚动/向上滚动时,单元格背后的背景)存在一些问题

有人可以帮助我为每个单元格和TableView背景提供背景吗?怎么做的?

正常细胞背景:(不确定它是否正确)

// CELL'S BACKGROUND-IMAGE
    self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_normal.PNG"]];
Run Code Online (Sandbox Code Playgroud)

选定的细胞背景:

// SELECTED CELL'S BACKGROUND-IMAGE
    UIView *viewSelected = [[[UIView alloc] init] autorelease];
    viewSelected.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"cell_highlighted.PNG"]];
    cell.selectedBackgroundView = viewSelected;
Run Code Online (Sandbox Code Playgroud)

iphone background uitableview

46
推荐指数
3
解决办法
6万
查看次数

cellForRowAtIndexPath中的ReusableCellWithIdentifier问题

在我的应用程序中,我有一个imageView和一个UILabel.对于ImageView,我已经为它分配了asynch Image并且它工作正常,但是当我滚动表时,第一行和最后一行的标签重叠.

这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    productObject=[appDelegate.productArray objectAtIndex:indexPath.row];
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    UILabel *nameLabel;
    if (cell == nil) 
    {

        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero     reuseIdentifier:CellIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleBlue;

    }   

    else 
    {

        AsyncImageView* oldImage = (AsyncImageView*)[cell.contentView viewWithTag:999];
        [oldImage removeFromSuperview];
    }

    CGRect nameLabelRect = CGRectMake(70,80,150,15);
    nameLabel = [[UILabel alloc] initWithFrame:nameLabelRect];    
    nameLabel.text = [NSString stringWithFormat:@"%@",productObject.productname];
    nameLabel.textAlignment = UITextAlignmentCenter;
    nameLabel.lineBreakMode = UILineBreakModeCharacterWrap;
    nameLabel.font = [UIFont boldSystemFontOfSize:15];
    nameLabel.backgroundColor = [UIColor clearColor];
    [cell.contentView addSubview: nameLabel]; …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview

2
推荐指数
1
解决办法
498
查看次数

标签 统计

iphone ×2

uitableview ×2

background ×1