create a UIWebView and load a website programmatically

前端 未结 3 641
执笔经年
执笔经年 2020-12-30 02:35

The following is my code. I simply want to load a website page and put a back button on screen. Don\'t know why nothing shows on the screen.

in .h

#i         


        
相关标签:
3条回答
  • 2020-12-30 03:22

    First Initialize Web view .Write The Below Code In Between [Super ViewDidLoad]; and Nsstring Inisilization.

    myWebView=[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
    myWebView.delegate=self;
    [self.view addSubview:myWebView]
    

    Then Load Request Your Code Will Work.

    0 讨论(0)
  • 2020-12-30 03:25

    Add the below code into your viewcontroller.m file viewDidLoad method.

    UIWebView *webView = [[UIWebView alloc]init];
    NSString *urlString = @"http://www.sourcefreeze.com";
    NSURL *url = [NSURL URLWithString:urlString];
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
    [webView loadRequest:urlRequest];
    [self.view addSubview:webView];
    

    for complete uiwebview example please refer the below link.

    http://sourcefreeze.com/ios-webview-uiwebview-example/

    0 讨论(0)
  • 2020-12-30 03:28

    Initialize your webView.

    UIWebView *tempWebview = [[UIWebView alloc]initWithFrame:theFrame];
    NSString *urlAddress = @"http://www.apple.com";
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    self.myWebView = tempWebview;
    [tempWebview loadRequest:requestObj];
    [tempWebview release];
    myWebView.delegate=self; 
    
    0 讨论(0)
提交回复
热议问题