以编程方式从另一个视图控制器错误启动webview

时间:2017-06-15 16:50:42

标签: ios objective-c uiwebview

这是我的主视图控制器:

#import "ViewController.h"
#import "WebViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    WebViewController *wvc = [[WebViewController alloc]init];
    [self presentViewController:wvc animated:NO completion:nil];
}

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



@end

这是webviewcontroller:

#import "WebViewController.h"

@interface WebViewController ()

@end

@implementation WebViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    UIWebView *webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 1024,768)];
    NSString *url=@"https://www.google.com";
    NSURL *nsurl=[NSURL URLWithString:url];
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
    [webview loadRequest:nsrequest];
    [self.view addSubview:webview];
}

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

谷歌页面没有加载,我得到的警告是

  

警告:尝试出现    谁的观点不在窗口   层次!

到底是怎么回事?

1 个答案:

答案 0 :(得分:1)

我建议仔细检查。按照您的代码,我刚刚确认了这一点:

//file1.qml

dial{
id: dial1
}



//file2.qml

dial{
 id: dial2
 }
相关问题