[英]UIViewContentModeScaleAspectFit not working for UIScrollView subview UIImageView
For hours I've been trying to figure out why the UIScrollView
won't display the images from a NSMutableArray
. 几个小时以来,我一直试图弄清楚为什么UIScrollView
不会显示来自NSMutableArray
的图像。
I realized the uiimageview objects are in the subview collection inside the UISCrollview but somehow the UIViewContentModeScaleAspectFit is ignored... How can I fit to scale then? 我意识到uiimageview对象位于UISCrollview内的子视图集合中,但不知何故忽略了UIViewContentModeScaleAspectFit ......我怎样才能适应缩放呢?
please, any tips? 请问,有什么提示吗?
- (void)viewDidLoad
{
[super viewDidLoad];
BookDalc* bookDalc = [[BookDalc alloc] init];
NSMutableArray* books = [bookDalc FindByIconID:IconID];
for(int i = 0;i<books.count;i++)
{
CGRect frame;
frame.origin.x = self.scrBook.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrBook.frame.size;
UIImageView *subview = [[UIImageView alloc] initWithFrame:frame];
subview.contentMode = UIViewContentModeScaleAspectFit;
BookEntity *currentModel = [books objectAtIndex:i];
UIImage *currentImage = [currentModel TheImage];
subview.image = currentImage;
[self.scrBook addSubview:subview];
}
self.scrBook.contentSize
= CGSizeMake(self.scrBook.frame.size.width * books.count, self.scrBook.frame.size.height);
}
The frame of self.srcBook might not be set. self.srcBook的框架可能未设置。
For more information read this answer. 有关更多信息,请阅读此答案。 Why am I having to manually set my view's frame in viewDidLoad? 为什么我必须在viewDidLoad中手动设置视图的框架?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.