質問

When I used tradition function

   [self.navigationController pushViewController:viewcontroller animated:YES];

or

   [self presentModalViewController:viewcontroller animated:YES];,

Everything is ok. But when I used

   [self.view addSubview:viewcontroller.view];

I can't do anything in next view, all view's membory pointer has gone. And it crashes all the time.

役に立ちましたか?

解決

I think your viewController object is declared locally. Make it class level variable (declare in .m file). Reason why your app crashes is you declare object locally and it is released after that function is finished. So no object for addSubView. When you push or present object is retained once and hence not released and application works. So if you want to use addSubView then make it class level variable so that it wont be released.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top