Ios UIWebView仅显示白色屏幕

Ios UIWebView仅显示白色屏幕,ios,objective-c,uiwebview,Ios,Objective C,Uiwebview,根据我找到的一些在线教程,我正在开发一个使用UIWebView的iOS示例应用程序。示例应用程序可以编译,但当我在iOS emulator上运行它时,该应用程序在转换为白色屏幕之前只显示文本“WebView”。应用程序只是在之后保持这样。只是加载到网页需要很长时间,还是我的应用程序有问题 ViewController.h的内容: #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIWe

根据我找到的一些在线教程,我正在开发一个使用UIWebView的iOS示例应用程序。示例应用程序可以编译,但当我在iOS emulator上运行它时,该应用程序在转换为白色屏幕之前只显示文本“WebView”。应用程序只是在之后保持这样。只是加载到网页需要很长时间,还是我的应用程序有问题

ViewController.h的内容:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end
不确定它是否有用,但以下是Main.storyboard的内容:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
    </dependencies>
    <scenes>
        <!--View Controller-->
        <scene sceneID="tne-QT-ifu">
            <objects>
                <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
                        <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <webView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vAN-PO-yTo">
                                <rect key="frame" x="50" y="28" width="600" height="600"/>
                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                            </webView>
                        </subviews>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
            </objects>
        </scene>
    </scenes>
</document>

将www添加到地址。否则就不行了

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    NSURL *url = [[NSURL alloc] initWithString:@"http://www.google.com"];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
    // replacing "[[NSURLRequest alloc] initWithURL:url]" with "[NSURLRequest requestWithURL:url]" doesn't seem to help
    [self.webView loadRequest:request];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

尝试在google.com之前添加www,但它仍然显示白色屏幕。您确定已将界面中的UIWebView正确连接到视图控制器吗?单击界面中的web视图,然后单击右侧“实用程序”菜单上最右侧的按钮,查看它是否作为引用插座连接到视图。它现在可以工作了。非常感谢!
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    NSURL *url = [[NSURL alloc] initWithString:@"http://www.google.com"];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
    // replacing "[[NSURLRequest alloc] initWithURL:url]" with "[NSURLRequest requestWithURL:url]" doesn't seem to help
    [self.webView loadRequest:request];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end