做的NSLog我有這個安裝在我上課的時候意外的行爲:IOS - 試圖從didViewAppear
- (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:@"[email protected]"]];
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
燦你在該方法中放置了一個斷點來查看它是否被命中?只需點擊想要代碼暫停的行上代碼左側的細條,如果它從不暫停,那麼該方法永遠不會被調用。 –
這究竟在哪裏? – JoshRagem
@Kris Gellci剛剛嘗試過。代碼確實到達那裏,但日誌永遠不會發生。也許我的日誌屏幕無法正常工作? – GeekedOut