[英]Loading UIView from UITableViewController
I am trying to call a UIView inside of a UITableViewController. 我试图在UITableViewController内部调用UIView。
JHWebViewController has been created in the storybaord. JHWebViewController已在storybaord中创建。
JHWebViewController *myWebView = [[JHWebViewController alloc] init];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
myWebView.request = requestObj;
[self presentViewController:myWebView animated:YES completion:nil];
The error I get is Property 'request' not found on object of type 'JHWebViewController *' 我得到的错误是在'JHWebViewController *'类型的对象上找不到属性'request'
You can write the relevant code in UITableView didSelectRowAtIndexPath method I hope it will work for you 您可以在UITableView didSelectRowAtIndexPath方法中编写相关代码,希望它对您有用
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath`
{
[self.view addSubview:myWebView.view];
}
You try try this: 您可以尝试以下方法:
JHWebViewController *myWebView = [[JHWebViewController alloc] init];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[myWebView loadRequest:requestObj];
myWebView.scalesPageToFit = YES;
[self.view addSubview:myWebView.view];
Maybe try to embed the web view in a modal view controller and present the controller modally. 也许尝试将Web视图嵌入到模式视图控制器中,然后模态显示控制器。 Declare a public NSURLRequest property and set it from the table view delegate method. 声明一个公共NSURLRequest属性,并从表视图委托方法中对其进行设置。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath`
{
YourEmbeddingViewController *evc = [[YourEmbeddingViewController alloc] init]; // subclass of UIViewController
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
evc.request = requestObj;
[self presentViewController:evc animated:YES completion:nil];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.