I have an app that uses a number of views, and it was getting pretty awkward swapping between them so I thought it might be an idea to make some code that would automatically go to a numbered page, load the appropriate view, then perform any setup that needed doing based upon that view. I came up with the following. The test page I've set up it swaps to OK and even sets the delegate properly, but it just won't perform any setup operations on the contents of the page, such as changing the text on the labels it contains or flicking the toggle switch to ON. I've been through the program step by step and all of the commands are being executed, but the results just don't show up on the final screen.
currentMenu is a UIViewController pointer that I aim at the current ViewController in use so that I know what to dismiss later. clusterMenu is a specific view controller of type ClusterMenu that I am using as a sample page to switch to.
It also occurs to me that the resources might not release properly with this code, but that's something I can deal with later once I can work out why it's not being set up correctly in the first place.
Here is the code:
UIViewController *vanishing = currentMenu;
if (page == 3){
clusterMenu = [[ClusterMenu alloc] initWithHeader:clusterMap.header];
[clusterMenu setDelegate:self];
clusterMenu.editSwitch.on = clusterMap.editMode;
[clusterMenu changeEditStatus];
currentMenu = clusterMenu;
}
[UIView transitionFromView:vanishing.view toView:currentMenu.view duration:0.5
options:UIViewAnimationOptionTransitionCurlUp
completion:^(BOOL done){[vanishing release];}];