在UITableViewCell子类中旋转UIImageView

时间:2012-05-01 23:22:58

标签: iphone objective-c ios ipad uiimageview

所以我有以下代码:

#define degreesToRadians(x) (M_PI * x / 180.0)

@implementation NewsFeedSubCell
@synthesize imageView_;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {


        CGRect frame = self.frame;
        frame.size.width = 20;
        frame.size.height = 20;
        self.frame = frame;
        self.contentView.frame = frame;

        UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.frame];
        imageView.transform = CGAffineTransformRotate(self.contentView.transform, degreesToRadians(90));
        [imageView setAutoresizingMask:UIViewAutoresizingNone];
        [self.contentView addSubview:imageView];
        self.imageView_ = imageView;
        [imageView release];



    }
    return self;
}

知道为什么这不旋转吗?

1 个答案:

答案 0 :(得分:2)

为什么要进行contentView的转换?尝试使用CGAffineTransformMakeRotation代替CGAffineTransformRotate