Web から画像を読み込んでおり、その下の HTML を UIScrollView に読み込んでいます。これは、tabbarcontroller 内の navigationController 内にあります。サブビューをロードすると、スクロールビューはスクロールしません。私は何が欠けていますか?
ビューDidLoadは次のとおりです。
- (void)viewDidLoad
{
NSURL *imageURL = [NSURL URLWithString:[[self exhibit] image]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];
if ([[UIScreen mainScreen] bounds].size.width < 600 ) {
CGSize newSize = CGSizeMake(300.0, 140.6);
UIGraphicsBeginImageContext(newSize);
[image drawInRect:CGRectMake(0.0, 0.0, newSize.width, newSize.height)];
image = UIGraphicsGetImageFromCurrentImageContext();
}
CGRect viewFrame = CGRectMake(0.0, 0.0, [[UIScreen mainScreen] bounds].size.width,
([[UIScreen mainScreen] bounds].size.height - [[self navigationController] navigationBar].bounds.size.height - [[[self tabBarController] tabBar] bounds].size.height));
NSLog(@"%@",NSStringFromCGRect(viewFrame));
UIScrollView *sv = [[UIScrollView alloc] initWithFrame:viewFrame];
[sv setScrollEnabled:YES];
[self setView:sv];
CGRect frame = CGRectMake(0.0, 0.0,image.size.width,image.size.height);
UIImageView *iv = [[UIImageView alloc] initWithFrame:frame];
[iv setImage:image];
[iv setContentMode:UIViewContentModeScaleAspectFit];
[iv setTranslatesAutoresizingMaskIntoConstraints:NO];
[iv setBackgroundColor:[UIColor redColor]];
[sv addSubview:iv];
[self setImageView:iv];
NSDictionary *nameMap = @{@"imageView" : [self imageView]};
NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[imageView]-10-|"
options:NSLayoutFormatAlignAllCenterX
metrics:nil
views:nameMap];
[sv addConstraints:horizontalConstraints];
NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[imageView]"
options:NSLayoutFormatAlignAllTop
metrics:nil
views:nameMap];
[sv addConstraints:verticalConstraints];
UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 150.0, 300.0, 600.0)];
[wv loadHTMLString:[[self exhibit] text] baseURL:nil];
[sv addSubview:wv];
[self setExhibitText:wv];
}
アップデート
次の行を追加しましたが、まだ変更はありません。全然スクロールできません。
[sv setContentSize:CGSizeMake(320.0, 750.0)];
[[wv scrollView] setScrollEnabled:NO];
[[wv scrollView] setBounces:NO];
[wv setUserInteractionEnabled:NO];