Short solution for short problems

iOS: Using multiple storyboards within a navigation controller.

I had a big story board file and I wanted to start to split it up in multiple storyboards containing views with shared functionality. First I found out how to open a different storyboard modally. But since the application uses a navigation controller at certain points, I also wanted to keep the navigation when opening some other storyboards. 

So iOS makes it really simple:

First instantiate the storyboard you want to navigate to (bundle can be nil if the story board is in the same bundle):

UIStoryboard * planningSB = [UIStoryboardstoryboardWithName:@"PlanningStoryboard"bundle:nil];

Then instantiate the initial view controller:

UIViewController * planningVC = [planningSB instantiateInitialViewController];

And last, just push this view controller into the view controllers collection of the current navigation controller.

[self.navigationControllerpushViewController:planningVC animated:YES];

Now the View controller of the second storyboard is loaded in the navigation controller. When pushed on the back arrow on the top, it will simply go back to the previous view controller and the second story board will be deallocated when the reference to its initial view controller is released.

Next is another example where I change the transition style:

UIStoryboard * planningSB = [UIStoryboardstoryboardWithName:@"PlanningStoryboard"bundle:nil];

UIViewController * planningVC = [planningSB instantiateInitialViewController];


[UIView transitionWithView:self.view duration:0.8 options:UIViewAnimationOptionTransitionCrossDissolve


                            [self.navigationController pushViewController:planningVC animated:NO];




 In my case I had a camera view that could be called from several views, I put this on a new storyboard and this works great. Since the camera view was also pointing to the search order view, I had to put the search order view also on a separate storyboard. Again my main story board got simpler.

So have a main story board, and separate as much as you can onto separate storyboards. I made a general class StoryBoardNavigation where I centralized all functions to call child storyboards.

Here is an example of this:

This function navigates to the storyboard called OrderLookupStoryboard and opens the view in start position.

+(void)NavigateToOrderLookupFrom:(UIViewController*)vc {UIStoryboard* sb =[UIStoryboard storyboardWithName:@"OrderLookupStoryboard" bundle:nil];UIViewController* vcTo =[sb instantiateInitialViewController];[UIView transitionWithView:vc.view duration:0.8 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{[vc.navigationController pushViewController:vcTo animated:NO];} completion:NULL];}

This function passes some parameters to the storyboard.

+(void)NavigateToCameraFrom:(UIViewController*)vc WithSelectedZone:(int)selectedZone {UIStoryboard* sb =[UIStoryboard storyboardWithName:@"CameraStoryboard" bundle:nil];MediaCapture* vcTo =[sb instantiateInitialViewController]; vcTo.selectedZone = selectedZone; vcTo.zoneSet = YES;[UIView transitionWithView:vc.view duration:0.8 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{[vc.navigationController pushViewController:vcTo animated:NO];} completion:NULL];}

This function opens the view in module transition style:

+(void)NavigateToSignatureFrom:(UIViewController*)vc withSignee:(NSString*)Signee{UIStoryboard* sb =[UIStoryboard storyboardWithName:@"SignatureStoryboard" bundle:nil];UIViewController* vcTo =[sb instantiateInitialViewController];((SignatureVC*) vcTo).Signee=Signee;[vcTo setModalTransitionStyle:UIModalTransitionStylePartialCurl];[vc presentViewController:vcTo animated:YES completion:nil]; 






Locating the Configuration file of an VSTO (excel) project

I was contacting WCF Webservices in an Excel VSTO project. Deploying this to the customers, they could use VBA as much as they want without exposing code to contact the database.  

My problem was that the message size was the default and therefore not enough. It was already deployed to a customer and he had already made a lot of changes. Re deploying would mean losing these changes. So I was planning on changing the binding on the client and server. There came the challenge. Changing it on the server was no problem, but finding the config file on the client was a BIG problem.

The path was located at: C:\Users\mderaeve\AppData\Local\Apps\2.0\V154RLC4.47N\73GCM0NZ.LX6\poed..vsto_268646e17c0b18d5_0001.0000_9bd2d9b28f73af10

Fortunatelly, there are not that many directories in the Local\Apps\2.0 so you can find the project fast. I found the path by putting this piece of code in the project and show it somewhere in the excel. Then I installed it and the path was printed out.

//Get the assembly information

System.Reflection.Assembly assemblyInfo = System.Reflection.Assembly.GetExecutingAssembly();


//Location is where the assembly is run from

string assemblyLocation = assemblyInfo.Location;


//CodeBase is the location of the ClickOnce deployment files

Uri uriCodeBase = new Uri(assemblyInfo.CodeBase);

string ClickOnceLocation = Path.GetDirectoryName(uriCodeBase.LocalPath.ToString());

Excel._Worksheet activeSheet = ((Excel._Worksheet)Application.ActiveSheet);


activeSheet.Cells[4, 2] = ClickOnceLocation;