objective-c - 在 UITableView 中选择单元格时创建 UIWebView

标签 objective-c ios xcode ipad ios4

我有以下代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    UIWebView *aWebView;
    aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(320, 0, 320, 480)];//init and create the UIWebView
    aWebView.autoresizesSubviews = YES;
    aWebView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
    //set the web view delegates for the web view to be itself
    [aWebView setDelegate:self];
    //Set the URL to go to for your UIWebView
    NSString *urlAddress = @"www.google.com";
    //Create a URL object.
    NSURL *url = [NSURL URLWithString:urlAddress];
    //URL Requst Object
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    //load the URL into the web view.
    [aWebView loadRequest:requestObj];
    //add the web view to the content view
    [self.view addSubview:aWebView];

}

单击任何单元格时,它应该创建一个 UIWebView 并转到 google.com,但由于某种原因,我收到以下错误:2011-12-04 23:47:56.825 AudStud[906:207] Unknown方案,什么也不做:www.google.com

最佳答案

您的 URL 缺少协议(protocol)部分。它应该是 http://www.google.com

关于objective-c - 在 UITableView 中选择单元格时创建 UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8378170/

相关文章:

ios - React-Native:更新后如何删除 NSUserDefaults?

ios - 使用 UISlider 应用 GPUImage 过滤器

ios - TextField 在按下完成时换行而不是关闭键盘 Xcode 10

iPhone 和 MySQL

ios - xcode - 从本地 html 文件加载 UIWebView

ios - 使用 Objective C 类的参数调用 Swift 函数

javascript - 在 Web View 中将视频流从 iOS7 摄像头发送到 JavaScript Canvas

ios - 定位服务的 Objective-C 问题

ios - 在 iOS 8 的 UISplitViewController 中动画显示/隐藏主视图

ios - 奇怪的 UIViewController hidesBottomBarWhenPushed 布局错误,仅在第一次推送 View Controller 时发生