Ios UINavigationController继承,视图将显示为未调用
我创建了一个子类Inherit from UINavigationController,我的所有导航控制器都继承自该类,当应用程序运行时,viewDidLoad从我的类中调用,但ViewWillDisplay不调用任何人知道吗? 正在添加子类ViewWill时将显示:Ios UINavigationController继承,视图将显示为未调用,ios,iphone,objective-c,oop,inheritance,Ios,Iphone,Objective C,Oop,Inheritance,我创建了一个子类Inherit from UINavigationController,我的所有导航控制器都继承自该类,当应用程序运行时,viewDidLoad从我的类中调用,但ViewWillDisplay不调用任何人知道吗? 正在添加子类ViewWill时将显示: //******************************************************************************************** //** vi
//********************************************************************************************
//** viewWillAppear
//*********************************************************************************************
- (void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self replacePng];
self.title = @"";
}
这是一节课:
//
// MyViewController.m
// Nifgashim
//
// Created by shim wi on 7/15/14.
// Copyright (c) 2014 Oded. All rights reserved.
//
#import "MyViewController.h"
@interface MyViewController ()
@end
@implementation MyViewController
@synthesize interstitial;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
sing = [singData sharedInstance];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//******************************************************************************************** ******
//** viewWillAppear *
//**************************************************************************************************
- (void) viewWillAppear:(BOOL)animated{
if (sing.adInt == sing.adCount)
{
[self loadInterstitial];
}
else{
sing.adCount++;
}
[super viewWillAppear:animated];
}
#pragma mark GADRequest implementation
//*********************************************************
//* GADRequest implementation *
//*********************************************************
- (GADRequest *)request {
GADRequest *request = [GADRequest request];
return request;
}
#pragma mark GADInterstitialDelegate implementation
//*********************************************************
//* interstitialDidReceiveAd *
//*********************************************************
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {
[self.interstitial presentFromRootViewController:self];
}
#pragma mark didFailToReceiveAdWithError implementation
//*********************************************************
//* didFailToReceiveAdWithError *
//*********************************************************
- (void)interstitial:(GADInterstitial *)interstitial
didFailToReceiveAdWithError:(GADRequestError *)error {
}
//*********************************************************
//* loadInterstitial *
//*********************************************************
-(void)loadInterstitial{
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.delegate = self;
self.interstitial.adUnitID = MY_BANNER_UNIT_ID;
[self.interstitial loadRequest:[self request]];
}/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
对于
MyViewController
的子类,您在viewwillbeen
中有什么内容?我在基类的顶部添加了函数,这样您就可以看到,您是否已通过断点确认没有调用子类viewwillbeen
?子类viewwillbeen被调用,但基类没有被调用,当您单步通过子类中的viewwillbeen
时,将调用基类的ViewDidLoad,当它到达[super viewwillbeen]
时会发生什么?或许我很困惑。当你说subclass时,你是指MyViewController
类还是最后一个子类?您可以显示最终的子类声明吗