现在的位置: 首页 > 综合 > 正文

WebView

2018年05月25日 ⁄ 综合 ⁄ 共 1369字 ⁄ 字号 评论关闭
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
    webFrame.origin.y += kTopMargin + 5.0;    // leave from the URL input field and its label
    webFrame.size.height -= 40.0;
    myWebView = [[UIWebView alloc] initWithFrame:webFrame];
    myWebView.backgroundColor = [UIColor whiteColor];
    myWebView.scalesPageToFit = YES;
    myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    myWebView.delegate = self;
    [self.view addSubview: myWebView];
    
    CGRect textFieldFrame = CGRectMake(kLeftMargin, kTweenMargin, self.view.bounds.size.width - (kLeftMargin * 2.0), kTextFieldHeight);
    urlField = [[UITextField alloc] initWithFrame:textFieldFrame];
    urlField.borderStyle = UITextBorderStyleBezel;
    urlField.textColor = [UIColor blackColor];
    urlField.delegate = self;
    urlField.placeholder = @"<enter a URL>";
    urlField.text = @"http://www.apple.com";
    urlField.backgroundColor = [UIColor whiteColor];
    urlField.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    urlField.returnKeyType = UIReturnKeyGo;
    urlField.keyboardType = UIKeyboardTypeURL;    // this makes the keyboard more friendly for typing URLs
    urlField.autocorrectionType = UITextAutocorrectionTypeNo;    // we don't like autocompletion while typing
    urlField.clearButtonMode = UITextFieldViewModeAlways;
    [self.view addSubview:urlField];

    [myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]]];

【上篇】
【下篇】

抱歉!评论已关闭.