iPhone SDK can't get UIScrollView to work with a UIWebView
Posted
by Maxwell Segal
on Stack Overflow
See other posts from Stack Overflow
or by Maxwell Segal
Published on 2010-03-20T11:26:44Z
Indexed on
2010/03/20
11:31 UTC
Read the original article
Hit count: 602
iphone-sdk-3.0
I am building an app that in part of it has two views - one portrait and one landscape. And I want to offer scrolling and pinch & zooming on the landscape orientation. I've built the two views and the simple UIImages in the landscape view all work OK but it does not seem to insert my UIWebView into the UIScrollView. I've done this before with UIImage and all was OK but I must be missing something here - can anybody help with some advice. I'm sure it's something very simple - perhaps to do with the adding of the subview??. Thanks in advance of your help.
I've shown the relevant parts of my code below:
@interface MonthViewController : UIViewController <UIScrollViewDelegate> {
MonthViewController *monthController;
IBOutlet UIView *portraitView;
IBOutlet UIView *landscapeView;
IBOutlet UIWebView *monthKWHChartPortrait;
UIWebView *monthKWHChartLandscape;
IBOutlet UIScrollView *scrollChartLandscape;
IBOutlet UIImageView *eLogoPortrait;
IBOutlet UIImageView *eLogoLandscape;
IBOutlet UIImageView *clientLogoPortrait;
IBOutlet UIImageView *clientLogoLandscape;
IBOutlet UIActivityIndicatorView *loadIndicatorPortrait;
IBOutlet UIActivityIndicatorView *loadIndicatorLandscape;
NSTimer *timer;
IBOutlet UILabel *test;
}
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollChartLandscape {
return monthKWHChartLandscape;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:duration];
if (toInterfaceOrientation ==UIInterfaceOrientationLandscapeRight) {
NSLog(@"right");
test.text=@"right";
NSString *urlAddressLandscape = @"http://PRIVATEURLHERE.aspx?WIDTH=440";
NSURL *urlLandscape = [NSURL URLWithString:urlAddressLandscape];
NSURLRequest *requestObjLandscape = [NSURLRequest requestWithURL:urlLandscape];
[self.monthKWHChartLandscape loadRequest:requestObjLandscape];
scrollChartLandscape.contentSize = CGSizeMake(monthKWHChartLandscape.frame.size.width, monthKWHChartLandscape.frame.size.height);
scrollChartLandscape.maximumZoomScale = 2.5;
scrollChartLandscape.minimumZoomScale = 0.6;
scrollChartLandscape.showsHorizontalScrollIndicator = YES;
scrollChartLandscape.showsVerticalScrollIndicator = YES;
scrollChartLandscape.clipsToBounds = YES;
scrollChartLandscape.delegate = self;
[self.scrollChartLandscape addSubview:monthKWHChartLandscape];
self.view=landscapeView;
//self.view.transform=CGAffineTransformMakeRotation(deg2rad*(90));
//self.view.bounds=CGRectMake(0.0, 0.0, 480.0, 320.0);
}
else
© Stack Overflow or respective owner