[英]rotating a UIImageView in UITableViewCell subclass
So I have the following code: 所以我有以下代码:
#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;
}
Any idea why this is not rotating? 知道为什么这不旋转吗?
Why are you taking the transform of the contentView? 你为什么要改变contentView? Try to use
CGAffineTransformMakeRotation
instead of CGAffineTransformRotate
尝试使用
CGAffineTransformMakeRotation
而不是CGAffineTransformRotate
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.