我面临UITableViewCell
我在做什么 在iPad的同一视图控制器的3个不同视图上有三个表视图。
其中, 在第一个tableview我有单元格内容视图按钮和文本。 当应用程序第一次加载时,文本+按钮显示良好。
但是一旦我旋转设备,按钮+文字就会消失。
我做错了什么。
提前致谢。
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier] autorelease];
}
if (tableView.tag == 1005)
{
if (indexPath.row == 0)
{
circle = [CAShapeLayer layer];
// Make a circular shape
circularPath=[UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 35, 35) cornerRadius:MAX(35, 35)];
circle.path = circularPath.CGPath;
// Configure the apperence of the circle
circle.fillColor = [UIColor blackColor].CGColor;
circle.strokeColor = [UIColor blackColor].CGColor;
circle.lineWidth = 0;
UIButton* cameraBtn = [[UIButton alloc] initWithFrame:CGRectMake(0,0, 35,35)];
cameraBtn.backgroundcolor = [UIColor redColor];
[cell.contentView addSubview: cameraBtn];
cameraBtn.layer.mask=circle;
UILabel *photoLbl = [[UILabel alloc]initWithFrame:CGRectMake(50, 0, 150, 30)];
photoLbl.backgroundColor = [UIColor clearColor];
photoLbl.font = [UIFont fontWithName:@"OpenSans" size:16];
photoLbl.text = @"Take photo";
[cell.contentView addSubview:photoLbl];
[photoLbl release];
[cameraBtn release];
cell.contentView.frame = cell.bounds;
cell.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
return cell;
}
我搜索了SO上的所有链接,但没有得到合适的解决方案。
答案 0 :(得分:0)
尝试升级您的模拟器,我遇到了同样的问题,当我在真实设备中进行测试时,它工作正常。