简体   繁体   English

旋转iOS设备后uitableviewcell消失

[英]uitableviewcell disappears after rotating iOS device

I am facing problem for UITableViewCell 我面临UITableViewCell问题

What I am doing, Having three table views on 3 different views of same view controller of iPad. 我正在做什么,在iPad的同一视图控制器的3个不同视图上具有三个表视图。

Among which, on 1st tableview I have cell with content view button and text. 其中,在第一个表格视图中,我具有带有内容视图按钮和文本的单元格。 Text+button is showing well when the app loads first time. 首次加载应用程序时,“文本+”按钮显示良好。

But as soon as I rotate the device the button+text disappears. 但是,一旦我旋转设备,按钮和文本就会消失。

What I am doing wrong. 我做错了。

Thanks in advance. 提前致谢。

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;
}

I searched for all links on SO, but didn't get suitable solution. 我搜索了SO上的所有链接,但没有找到合适的解决方案。

尝试升级您的模拟器,我遇到了同样的问题,当我在真实设备中对其进行测试时,它运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM