【问题标题】:setting background in uitableview在uitableview中设置背景
【发布时间】:2012-09-05 11:33:45
【问题描述】:

嗯,我有一个表格视图,我想设置背景。

我试过了:

self.mapMain.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"maptest.png"]];

还有这个:

NSString *backgroundPath = [[NSBundle mainBundle] pathForResource:@"maptest" ofType:@"png"];
UIImage *backgroundImage = [UIImage imageWithContentsOfFile:backgroundPath];
UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage];
self.mapMain.backgroundColor = backgroundColor;
[backgroundColor release];

但问题是这样的:我可以看到图像,但它就像在每个单元格中重复一样。如果我在列表之后滚动,我可以看到图像的其余部分。我想要的是图像是静态的,而不是在每个单元格中重复。所以image是iphone屏幕的高度,每个cell的高度是80。

我也尝试在我的视图控制器中插入一个 UIImageview,然后 做了Edit>Arrange>send to Back,但发送到后面不可点击。

【问题讨论】:

    标签: ios xcode uitableview uiimageview


    【解决方案1】:

    在 viewDidLoad 中试试这个

    [self.tableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"maptest"]]];
    

    【讨论】:

      猜你喜欢
      • 2014-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      相关资源
      最近更新 更多