2

私のクラスには次の設定があります。

- (void)viewDidAppear:(BOOL)animated
{
    NSLog(@"test");
    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"get_business_ideas" ofType:@"html"];
    NSURL *url = [NSURL fileURLWithPath:htmlFile];
    NSURLRequest *rq = [NSURLRequest requestWithURL:url];
    [theWebView loadRequest:rq];
}

NSLogステートメントがログ画面に表示されることはありませんが、uiWebViewがレンダリングされるため、残りのコードは機能しているようです。これはどうやってできるの?これは新しいプロジェクトなので、ログが表示されるように何かを設定する必要があったのでしょうか。

ありがとう!

更新:ファイル全体は次のとおりです。

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    {
        //load iphone image
        UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"building"]];
        imgView.frame = self.view.bounds; // to set the frame to your view's size
        [self.view addSubview:imgView];
        [self.view sendSubviewToBack:imgView];
    }
    else
    {
        //load ipad image
        UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"building@2x"]];
        imgView.frame = self.view.bounds; // to set the frame to your view's size
        [self.view addSubview:imgView];
        [self.view sendSubviewToBack:imgView];
    }

    NSLog(@"2");
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

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

@end
4

1 に答える 1

3

スーパーコールを追加すると、これが修正されますか?

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    NSLog(@"test");
    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"get_business_ideas" ofType:@"html"];
    NSURL *url = [NSURL fileURLWithPath:htmlFile];
    NSURLRequest *rq = [NSURLRequest requestWithURL:url];
    [theWebView loadRequest:rq];
}

(ここで問題を解決する結果が何であっても...このメソッドで[スーパー]呼び出しを保持していることを確認してください... APIドキュメントごとに必要です)。

下部ペインが表示されているとのことでしたが、デバッグ メッセージは表示されません。下部パネルの中央の表示アイコンをクリックして、変数に加えてコンソール セクションが表示されていることを再確認します (Xcode の右上にある同様のボタンではありません)。

コンソール

于 2012-12-01T02:06:44.970 に答える