【发布时间】:2023-03-31 23:29:02
【问题描述】:
我有一个当前嵌入了帮助文件的现有应用程序;我正在尝试更改它们,以便它们访问 Internet 以获取本地化的帮助文件。这是我的代码:
// make the popover
UIViewController* popoverContent = [UIViewController new];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 450, 500)];
popoverView.backgroundColor = [UIColor colorWithWhite:(CGFloat)1.0 alpha:(CGFloat)1.0]; // frame color?
popoverContent.view = popoverView;
//resize the popover view shown in the current view to the view's size
popoverContent.preferredContentSize = CGSizeMake(450, 500);
NSURL *indexURL = [NSURL URLWithString:@"google.com"];
// add the UIWebView for RichText
webView = [[UIWebView alloc] initWithFrame:popoverView.frame];
webView.backgroundColor = [UIColor whiteColor]; // change background color here
// add the webView to the popover
[webView loadRequest:[NSURLRequest requestWithURL:indexURL]]; // load it...
[popoverView addSubview:webView];
// if previous popoverController is still visible... dismiss it
if ([popoverController isPopoverVisible]) {
[popoverController dismissPopoverAnimated:YES];
}
//create a popover controller to display the HELP text
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
[popoverController presentPopoverFromRect:((UIButton *)boHelpGeneralSetup).frame inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
此代码在嵌入帮助文件时有效;为什么当我尝试从 Internet 上的网页获取文件时它不起作用?
【问题讨论】:
-
什么时候嵌入哪个文件?
-
一个 HTML 文件,包含网页上的 exact 措辞。这与问题无关。
-
尝试使用 http:// 包含整个地址
-
@Mr.T 做到了! (我知道这让它更尴尬!)请重写您的评论作为答案,我会标记它,以便您获得积分。非常感谢... SD
标签: objective-c uiwebview nsurl