![](/img/trans.png)
[英]Displaying UIImageView in a subclass of UITableViewCell in cellForRowAtIndexPath
[英]rotating a UIImageView in UITableViewCell subclass
所以我有以下代碼:
#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;
}
知道為什么這不旋轉嗎?
你為什么要改變contentView? 嘗試使用CGAffineTransformMakeRotation
而不是CGAffineTransformRotate
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.