0

状態の復元を使用して、アプリの以前のビューとデータを復元しています。最初のビュー コントローラーでボタンをクリックすると、2 番目のビュー コントロールをプッシュします。この場合、2 番目のビュー コントローラー データを復元できます。最初のView Controllerでボタンがクリックされたときに、最初のView ControllerのサブビューとしてのView Controllerビュー、encodeRestorableStateWithCoder:およびdecodeRestorableStateWithCoder:が2番目のView Controllerで呼び出されませんでした。2番目のView Controllerデータを復元できません。サブビューを復元するために他の構成を行う必要がありますかデータ ?

//Firstviewcontroller

-(IBAction)moveToNextViewController:(id)sender {

 SecondVeiwController *sec_VC=[[SecondVeiwController alloc]initWithNibName:@"SecondVeiwController" bundle:[NSBundle mainBundle ]];
    sec_VC.restorationIdentifier=@"SecondVeiwController";

    [self.view addSubview:tab_cnt_1.view];

}





//Secondviewcontroller

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.restorationIdentifier=@"Secondviewcontroller";
        self.restorationClass=[self class];
    }
    return self;

}

+(UIViewController *)viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder
{

    UIViewController * myViewController =
    [[Secondviewcontroller alloc]
     initWithNibName:@"Secondviewcontroller"
     bundle:[NSBundle mainBundle]];

    return myViewController;

}
4

1 に答える 1