在我的应用程序中,每次用户点击一个 url 时,都会弹出一个 uipopover 来显示该网站。问题是弹出框只有 320x480,但 uiwebview 与 iPad 视图一样大。
如何使 uiwebview 以较小的视图加载网站。
谢谢。这是我的代码的一部分:
- (IBAction)openWeb:(id)sender{
ShowWebOnBrowserViewController *swobvc = [self.storyboard instantiateViewControllerWithIdentifier:@"WebView"];
swobvc.title = self.companyName.text;
swobvc.companyWebURL = self.web.titleLabel.text;
swobvc.companyWebView.scalesPageToFit = YES;
swobvc.companyWebView.scrollView.contentSize = CGSizeMake(320,480);
swobvc.companyWebView.scrollView.frame = CGRectMake(0, 0, 320, 480);
swobvc.companyWebView.frame = CGRectMake(0, 0, 320, 480);
popOverController = [[UIPopoverController alloc] initWithContentViewController:swobvc];
popOverController.popoverContentSize = CGSizeMake(320, 480);
[popOverController presentPopoverFromRect:[((UIButton*)sender) bounds] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
//in popover class
-(IBAction)loadURL:(id)sender
{
NSString* webText = self.companyWebURL;
webText = [webText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSURL *webURL = [NSURL URLWithString:webText];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:webURL];
[self.companyWebView loadRequest:requestObj];
self.companyWebView.scalesPageToFit = YES;
}