Search code examples
iphonethree20url-mapping

Difficulties with TTURLMap and the navigation items


I'm using the TTURLMap to map to a normal view (map from:toViewController:). I push a given view using TTOpenURL(url), everything works, etc etc, but the 'Back' navigation item (top left bar button) holds the title of the previous view, instead of 'Back'.

I've tried editing the title of this button in the loadView and viewDidLoad methods of the view controller being pushed to no avail. How can I make this navigation item read 'Back'?

Note: I do know i could make a completely custom button, but the idea is to keep the special os generated 'pointy' back button image, just with a different title.


Solution

  • I tried a few methods to change the back button, but I eventually created a custom back button using the three20 styles. It uses shapes and not UIImage, so it looks pretty much native.

    In the application style sheet, i have this style class:

    ///////////////////////////////////////////////////////////////////////////////////////////////////
    - (TTStyle*)grayBackwardButton:(UIControlState)state {
      TTShape* shape = [TTRoundedLeftArrowShape shapeWithRadius:4.5];
      UIColor* tintColor = RGBCOLOR(102, 102, 102);
      return [TTSTYLESHEET toolbarButtonForState:state shape:shape tintColor:tintColor font:nil];
    }
    

    And then I create a TTButton while hiding the standard back button.

     [self.navigationItem setHidesBackButton:YES];
    
     TTButton* backButton = [TTButton 
                          buttonWithStyle:@"grayBackwardButton:" 
                          title:NSLocalizedString(@"BACK", @"")];
     backButton.frame = CGRectMake(0,0,55,32);
     [backButton addTarget:self action:@selector(dismissPlayer) forControlEvents:UIControlEventTouchUpInside];