- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在将 UITableView 的背景设置为 UIImageView 时遇到问题(请参阅下文了解我这样做的原因),设置 View 后,它工作正常,并与 UITableView 一起滚动,但它隐藏了 UITableView 的元素表格 View 。
我需要一个 UIImageView 作为 UITableView 的背景。我知道以前已经回答过这个问题,但答案是使用:
[UIColor colorWithPatternImage:[UIImage imageNamed:@"myImage.png"]];
或者类似的东西(我需要使用):
UIImageView *background = [MainWindow generateBackgroundWithFrame:tableView.bounds];
[tableView addSubview:background];
[tableView sendSubviewToBack:background];
我需要使用后者的原因是因为我的generateBackgroundWithFrame方法,它需要一个大图像,并在该图像周围绘制指定尺寸的边框,并剪辑图像的其余部分:
+ (UIImageView *) generateBackgroundWithFrame: (CGRect)frame {
UIImageView *background = [[[UIImageView alloc] initWithFrame:frame] autorelease];
background.image = [UIImage imageNamed:@"globalBackground.png"];
[background.layer setMasksToBounds:YES];
[background.layer setCornerRadius:10.0];
[background.layer setBorderColor:[[UIColor grayColor] CGColor]];
[background.layer setBorderWidth:3.0];
return background;
}
请注意:我知道这可能会对性能产生不良影响,但我没有资源来为应用程序中的每个潜在屏幕制作这些图像。请不要用无意识的“你不应该这样做”的回答来回答这个问题。我知道这可能是错误的做法。
如何显示我的 UITableView 控件元素?我的代表是否做错了什么?这是一个简化版本:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithFrame:CGRectMake(20, 20, 261, 45)
reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
UIImage *rowBackground;
NSString *imageName = @"standAloneTVButton.png";
rowBackground = [UIImage imageNamed:imageName];
UITextView *textView =
[[UITextView alloc] initWithFrame:CGRectMake(0, 5, 300, 200)];
textView.backgroundColor = [UIColor clearColor];
textView.textColor = [UIColor blackColor];
textView.font = [UIFont fontWithName:@"Helvetica" size:18.0f];
Purchase *purchase =
[[PurchaseModel productsPurchased] objectAtIndex:indexPath.row];
textView.text = [purchase Title];
selectedTextView.text = textView.text;
UIImageView *normalBackground =
[[[UIImageView alloc] init] autorelease];
normalBackground.image = rowBackground;
[normalBackground insertSubview:textView atIndex:0];
cell.backgroundView = normalBackground;
[textView release];
}
return cell;
}
最佳答案
所以到目前为止这个问题的答案是向背景 View 添加一个标签,然后执行以下操作:
- (void)tableView: (UITableView *)tableView willDisplayCell: (UITableViewCell *)cell forRowAtIndexPath: (NSIndexPath *)path {
[tableView sendSubviewToBack:[tableView viewWithTag:BACKGROUNDVIEW_TAG]];
}
我不太喜欢这个,因为我对每个单元格都这样做,但我似乎找不到 allCellsDidLoadForTableView: (UITableView *)tableView
某种方法。
关于iphone - UITableViewCells出现在backgroundView后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2664596/
对于我的 tableview,我做了一个自定义背景 View ,我在我项目的每个 tableView 上调用 viewDidLoad: - (void)viewDidLoad{ [super
我有一个带有可变高度单元格的UITableView。我不想使用背景图像,而是想设置一个具有我想要的样式的 backgroundView 。目前,我不知道如何根据单元格的高度动态更改 backgroun
我很难让单元格的 backgroundView 显示出来。 代码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRow
我有带有背景图像的 UITableView 然后我滚动它 我有像背景 imageView 滚动一样的视差效果。问题是我的图像完成后我有 tableView 背景。是否可以制作无限 imageView?
我已经在 cellForRowAtIndexPath 中检查了如何使用 UITableView 制作背景: UIImageView *tempImageView = [[UIImageView all
我有一个分组 TableView ,我添加了一个自定义背景 View ,我在代码中设置这些,在普通和视网膜 iPhone 的 iOS 模拟器上一切正常,但在设备上它们根本不显示,它只是一个完全没有背景
我想为我的表格 View 单元格添加自定义背景和选定的背景图像。目前看来,当单元格被重用时,背景图像会搞砸,顶部单元格将使用底部单元格图像,等等。 在这种情况下,我是否错误地重用了单元格? - (UI
我正在尝试更改搜索栏文本字段的背景颜色,我已经搜索并尝试了很多解决方案,但这些都不起作用。 所以,请任何人都可以告诉我确切的解决方案。我们如何更改搜索栏文本字段的背景颜色? /// used to p
我对 backgroundView 属性有疑问。我试图像这样将 imageView 添加到背景中 let backgroundImage = UIImage(named: "Fridge_ba
我使用此函数在我的 TableView 为空时添加背景 View 。 func emptyTableViewMessage(with message: String) { let messag
我已经能够将我想要的渐变应用于我的 UICollectionViewCell 的背景 View 。但每次我重新加载单元格时,它都会再次应用我的渐变,累积所有渐变。 首先这里是我的渐变方法: stati
我正在写一些相对简单的东西,或者我是这么想的。 首先是代码,如果我的服务器没有返回结果,我会尝试将图像放在 UICollectionView 的背景上。图片是 200 x 200: UIView *m
我正在开发一个 iPad 应用程序来帮助我在国外管理我的开支。 我有一个带有经典主视图和详细 View 的 Split View。在主视图中有费用 list ,在明细 View 中,你猜怎么着?每一笔
我目前正在将 UITableViewCells 的背景 View 设置为从 eBay 的 API 中提取的图像。 cell.backgroundView = [[UIImageView alloc]
我有一个 UITableView,它使用带有自定义 backgroundView 的单元格。我正在按照建议在 tableView:cellForRowAtIndexPath:indexPath: 中分
我有一个带有自定义 backgroundView 的表格单元格,它在纵向时看起来很棒,但是当我移动到横向时,backgroundView 会被拉伸(stretch)以匹配横向宽度。我怎样才能使 bac
我在 UIViewController 中有一个 UITableView 嵌套在 UITabBarController 中,它有多个部分,每个部分都有一个自定义部分标题,它是一个子类一个UIView。
我遇到的问题是,当标签应该锚定到安全区域布局指南时,它却锚定到屏幕的底部边缘。这会将标签置于 iPhone 线之上。 这是代码... class CustomTableViewController:
我在使用带有自定义 drawRect: 的自定义 backgroundView 的自定义 UITableViewCell 时遇到问题 当用户选择我调用的单元格时 [tableView beginUpd
我想将我的表格 View 背景放在导航栏下方。当我尝试更改框架时没有任何反应.. UIImageView *imageView = [[UIImageView alloc] initWithFram
我是一名优秀的程序员,十分优秀!