簡體   English   中英

選項卡式應用程序(Xcode)中的UIWebView

[英]UIWebView in tabbed application (Xcode)

我剛剛開始學習Xcode,並且遇到了一些問題...

我在Xcode 4.3中制作了一個選項卡式應用程序,該應用程序按需運行。 但是我之前制作了一個簡單的UIWebView應用程序,現在我想在新應用程序的選項卡之一中實現該應用程序。

這是我在FirstViewController的類中所做的:

//  FirstViewController.h
//  SafeLine
//
//  Created by Camilla Fröberg on 2012-03-27.
//  Copyright (c) 2012 SafeLine Sweden AB. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController {

    IBOutlet UIWebView *webDisplay;
}

@property(nonatomic,retain) UIWebView *webDisplay;


@end

和FirstViewController.m:

//  FirstViewController.m
//  SafeLine
//
//  Created by Camilla Fröberg on 2012-03-27.
//  Copyright (c) 2012 SafeLine Sweden AB. All rights reserved.
//

#import "FirstViewController.h"

@interface FirstViewController ()


@end

@implementation FirstViewController
@synthesize webDisplay;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {

    NSString *urlAddress = @"http://www.google.com";

    //Create a URL object.
    NSURL *url = [NSURL URLWithString:urlAddress];

    //URL Requst Object
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    //Load the request in the UIWebView.
    [webDisplay loadRequest:requestObj];



    [super viewDidLoad];
}



// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


@end

運行該應用程序時,我不會收到任何錯誤消息,並且不會顯示該網站,而只會顯示一個空視圖...

任何幫助表示贊賞!

//最好的問候來自瑞典的卡米拉

我認為,您應該檢查是否已將Interface Builder中的UIWebView與IBOutlet連接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM