gpt4 book ai didi

ios - 尝试从 didViewAppear 执行 NSLog 时的意外行为

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:12:46 24 4
gpt4 key购买 nike

我在类里面有这个设置:

- (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

最佳答案

添加 super 调用是否为您解决了这个问题?

- (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 文档,这是必需的)。

您提到您显示了底部 Pane ,但没有显示任何调试消息。通过单击底部面板上的中间显示图标(不是 Xcode 右上角看起来相似的按钮),仔细检查除了变量之外还显示了控制台部分:

Console

关于ios - 尝试从 didViewAppear 执行 NSLog 时的意外行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13655663/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com