Archive for June, 2012

Undo checkout for unchanged files in TFS 2010

This is a really annoying one- I’ll often open files and not make any changes, but perhaps hit save out of habit making TFS check the file out. It will then hang about in pending changes until I manually go through the entire list checking each file for changes, only for TFS to helpfully inform me the files are identical! If you have TFS power tools you can run the following from a command line (having cd’ed to your solutions directory);

tfpt uu /recursive /noget

This will check all files and ask if you wish to undo checkout for identical files. Simples. But even simpler.. I found this article on Antoine Aubry’s blog detailing how to create a menu item in visual studio making this impossibly easy!

The balls of it (incase the site ever disappears!) is to go to tools> external tools> and then add a new item with the following configuration;

Title &Undo fake changes
Command %windir%\System32\cmd.exe
Arguments /C echo y | “%ProgramFiles(x86)%\Microsoft Team Foundation Server 2010 Power Tools\TFPT.EXE” uu /recursive /noget
Initial directory $(SolutionDir)

1 Comment

Rotating child UIView when parent UITabBar or UINavigationController isn’t rotatable!

I’m building an app at the moment, with what is most likely a pretty fairly use case. It is a tab based app (Using StoryBoard/ iOS5.0/ XCode 4.3.2) , so at the top I have a UITabBarController, UINavigationController’s coming off of a few different tabs, then UIViewControllers coming off of those.

I DON’T want the home screen’s to be rotatable, but I do want one of my child UIView’s (a picture gallery, of course!) to be rotatable.

My UITabBarController at the root of the application had the following method;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

This will make sure the views at the top don’t rotate, so I figured I would just add add the following to my gallery view controller to make just that one rotatable;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{   
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

But I found nothing happened when I rotated. I set a bunch of break points and found the method in my gallery detail controller wasn’t even hit, but the parent TabBarControllers method was still being hit. The trouble is, you can’t rotate a view unless it’s parent is marked as rotatable.

After some head scratching, the solution was actually pretty simple- I created a switch on my root TabBarController “allowRotation”, then adjust the shouldAutorotateToInterfaceOrientation method in the tabBarController to;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (self.allowRotation)
        return YES;
    else
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

Then in my gallery detail view I set that switch to true when you enter the view;

-(void) viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    RootTabBarController *tabcontrol = (RootTabBarController*)[self tabBarController];
    tabcontrol.allowRotation = YES;
}

And when you click the back button at the top of the view, I quickly set the switch back to false;

- (void)willMoveToParentViewController:(UIViewController *)parent
{
    RootTabBarController *tabcontrol = (RootTabBarController*)[self tabBarController];
    tabcontrol.allowRotation = NO;
}

I tried doing this on viewWillDisappear and a bunch of other methods, but found none of them fired early enough to get in there before the back button fired off it’s magic to prepare the parent views rotation.

NOTE: Make sure you’re app has rotation enabled in the Project Target “Summary” sheet, otherwise none of this will work!

2 Comments