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];
}

(无论最终在这里解决您的问题...确保在此方法中保留 [super] 调用...根据 API 文档,这是必需的)。

您提到您显示了底部窗格,但没有显示调试消息。通过单击底部面板上的中间显示图标(不是 Xcode 右上角的类似外观按钮),仔细检查控制台部分是否显示在变量之外:

安慰

于 2012-12-01T02:06:44.970 回答