带背景图像的自定义表格视图单元 - 宽度问题
我有一个自定义单元格(在 IB 中设置),其背景图像宽度为 320px。单元格的宽度也是 320。当我运行我的应用程序时,单元格的右侧有大约 5 像素的白色。换句话说,我的图像没有覆盖屏幕的整个宽度。我的代码如下所示:
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {
static NSString *OffensivePlayerCellIdentifier = @"OffensivePlayerCellIdentifier";
OffensivePlayerCell *cell = (OffensivePlayerCell *)[tableView dequeueReusableCellWithIdentifier: OffensivePlayerCellIdentifier];
if( cell == nil ) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed: @"OffensivePlayer" owner: self options: nil];
cell = [nib objectAtIndex: 0];
}
return cell;
}
有什么想法吗?
I have a custom cell (set up in IB) with a background image of width 320px. The width of the cell is also 320. When I run my app, there is about 5 pixel of white on the right side of the cells. In other words, my image doesn't cover the entire width of the screen. My code looks like this:
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {
static NSString *OffensivePlayerCellIdentifier = @"OffensivePlayerCellIdentifier";
OffensivePlayerCell *cell = (OffensivePlayerCell *)[tableView dequeueReusableCellWithIdentifier: OffensivePlayerCellIdentifier];
if( cell == nil ) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed: @"OffensivePlayer" owner: self options: nil];
cell = [nib objectAtIndex: 0];
}
return cell;
}
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我没有将图像直接应用到单元格的背景,而是尝试添加图像视图并将图像应用到该视图。现在可以了。不知道为什么。奇怪的行为。
Well, instead of applying the image directly to the background of the cell, I tried adding an image view and applying the image to that. Now it works. Don't know why. Strange behavior.