更改tableView的框架会导致我的应用程序出现问题

时间:2011-08-04 11:40:02

标签: iphone ios ipad uitableview

我希望借助我的iPad应用中的tableView来展示一种画廊类型的东西。 5个图像应以纵向模式显示,8个应以横向模式显示。为了实现这一功能,我已经完成了以下工作。

1-我采取了tableView并将其旋转90度

2-我再次将tableView单元旋转-90度,以便我可以将图像放入其中。

3-我在TableView中放置了一些图像并将其添加到我的scrollView。

4 - 我已经为我的tableView设置了不同的纵向和横向框架......

if(UIInterfaceOrientationIsPortrait(self.interfaceOrnetation)){
    myTableView.frame = CGRectMake(0,0,768,200);

}
 else{
   myTableView.frame = CGRectMake(0,0,1024,200);
}

5 - 我也在使用didRotateFrominterfaceOrientation方法中的上述行更改帧。

我正在使用以下代码加载tableView

中的图像
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{



if (cell==nil) {
            NSLog(@"count ");

            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewStylePlain reuseIdentifier:cellIdentifier] autorelease];

            UILabel *pageNumberLabel = [[UILabel alloc] init];
            pageNumberLabel.tag = 10;

            pageNumberLabel.frame = CGRectMake(35, -10, 100, 50);
            [cell.contentView addSubview:pageNumberLabel];

            UIImageView *thumbnailImageView = [[UIImageView alloc] init];
            thumbnailImageView.tag = 20;
            thumbnailImageView.frame = CGRectMake(10, 35, 140, 160);
            [cell.contentView addSubview:thumbnailImageView];

        }
        id<PageDataSource> pd = [kbDataSource pageAtIndex:indexPath.row];

        UILabel *pageLabel = [cell viewWithTag:10];
        pageLabel.backgroundColor = [UIColor clearColor];
        pageLabel.text = [NSString stringWithFormat:@"Page %d",indexPath.row+1];
        pageLabel.textColor = [UIColor whiteColor];

        UIImageView *thumbnail = [cell viewWithTag:20];
        thumbnail.image = [pd thumbnailImageForPageNumber:indexPath.row+1];

        cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.transform = CGAffineTransformMakeRotation(M_PI/2);
        return cell;
    }

框架第一次工作正常。但是,当我旋转设备时,tableView中的图像不会显示。我不知道问题出在哪里..再次,如果我不改变旋转后的框架,它工作正常,所有的图像都显示出来...是我在表格中缺少的东西吗???

1 个答案:

答案 0 :(得分:1)

听起来你的图像定位是关闭的。图像的x和y位置是什么?我想你在旋转时会发现你的图像在包含的视图框之外,因此你看不到它们。

但是,您是说要在滚动视图中添加tableview?你不应该这样做。

相关问题