0
在我的應用程序中,每當用戶點擊一個網址時,uipopover就會彈出顯示網站。 問題是popover只有320x480,但uiwebview和iPad視圖一樣大。在uipopover中加載uiwebview
如何使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;
}
感謝您的答覆,但它沒有奏效! –
您可以發佈它在模擬器中的樣子嗎? –
此外,在webview的scrollView屬性上設置contentSize,就像我在答案中添加的那樣。 –