문제

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