Question

i am developing an application which would have many subviews like the flow of instagram and picyou kind of social networking apps the flow is image->detail image->any comment->username->following->username->image username->image->detail image->any comment->username->following->username->image username->damn this is infinite never stops.....

and never gets memory warning or crashed by memory issue...

i am using navigation controller but still after some time of navigation changing some viewcontrollers it gives me error like this *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported (<ViewController: 0x6d97110>)'

i want to do same like this on pressing back you will also get all datas back. do you have any idea how to do like this.?

Was it helpful?

Solution

UINavigationController automatically supports this behavior you are describing. Memory efficient and potentially infinite. Every time you want to go from one piece of your app to the next you just use code similar to this.

ViewController *vc = [[ViewController alloc] init];
//customize ViewController
[self.navigationController pushViewController:vc animated:YES];

So if you want to go from a photo to a photo detail view, you just push the photo detail view controller when the button is pressed. Even if your in a photo detail view controller already you can push another one from that class. Just make sure you create a separate instance. Judging by your error, I think that is your problem now.

I have also found it best to create a custom initializer for these kinds of view controllers. For a photo detail view use something like.

-(id)initWithPhoto:(Photo*)photo;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top