mar*_*oko -1 frame uitableview uiimageview ios
我有一个cellForRowAtIndexPath方法,它使用一个开关来构建像这样的单元格:
switch (indexPath.row) {
case 0:
cell.imageView.image = [UIImage imageNamed:@"Usar mi ubicacion actual.jpg"];
[cell.imageView setFrame:CGRectMake(5, 5, cell.imageView.image.size.width, cell.imageView.image.size.height)];
break;
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我改成了这个:
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"] autorelease];
switch (indexPath.row) {
case 0:
self.locationButtonImageView.image = [UIImage imageNamed:@"Usar mi ubicacion actual.jpg"];
//cell.imageView.image = [UIImage imageNamed:@"Usar mi ubicacion actual.jpg"];
break;
Run Code Online (Sandbox Code Playgroud)
单元格加载时没有按钮图像.如果我点击单元格,则切换工作并显示所选按钮图像,然后继续切换.所以这可能是装载太晚的问题,对吧?
UITableViewCell默认样式不能被位置覆盖.
您需要自定义单元格并使用xib文件imageView将其自己添加到其contentView子类或子类中并添加imageView到其中
| 归档时间: |
|
| 查看次数: |
1352 次 |
| 最近记录: |