Thanks for all your help, as usual, i am looking for some more information…
Regarding view controllers, i am trying to develop an application with multiple views.
View Controller loads from View A using presentModalViewController – and loads View B from there – also works fine, but i have some nagging questions…
View A has a table in it, which drills down to View B, and i can move back to view A usig dismissModalViewController, but once back in View A i can’t access the table in View A.
What happens to controls/variables in View A when View B is pushed? is the dealloc called when View B is called? If i wish to access controls/variables when View B is dismissed and View A comes back into view, what do i need to do?
Is there some article that can educate on this?
ANy help is highly appreciated
To re-iterate
- View Controller initiates a page from View x
- View X loads – View A with a table into the view using presentModalViewController
- table is released in View A’s dealloc
- View B loads fine, works fine – dismissing the view B controllers takes back to View A
- At this point, i would like to reload the table in View A once it comes back onto the screen
I am pretty sure there are many other fellow members who are in this kind of situation
Here is my code, in bits and pieces
startPage – (This is the application’s home page) with a Start Button, contains
View Controller -> View
On clicking the start button, am loading a viewcontroller called ViewA(View Controller -> View), with the following code
UIViewController *viewA= [[viewA alloc] initWithNibName:@"viewA" bundle:nil];
viewA.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[naviControl presentModalViewController:viewA animated:YES];
[viewA release];
On picking a table row in ViewA, another viewcontroller ViewB(View Controller -> View) is called with the follwoing code
UIViewController *viewB= [[viewB alloc] initWithNibName:@"viewB" bundle:nil];
viewB=UIModalTransitionStyleCoverVertical;
[self viewB animated:YES];
ViewB is dismissed and VIewA is shown with code
[self dismissModalViewControllerAnimated:YES];
At this point, with some NSLogs, when ViewB is dismissed, only viewWillAppear is called on ViewA, not viewDidLoad and if i try to reload data on the table in ViewA, the app crashses with EXC_BAD_ACCESS
Thanks
Veeru
First of all, please correct following statement:
to
and secondly you will need to understand the memory management and flow of view controllers, e.g.
Solution:
If you are trying to use multiple navigation screens in your application, you should only use pushViewController method of UINavigationController which keeps the instances of viewcontroller until you explicitly release them.
Also be careful of using local instances or object instances and their retain count, keep track of alloc and release i.e. retain count, it should not be 0 unless you want them.
Hope this will help…