MicroStrategy ONE

Hide the MicroStrategy Navigation Bar in iOS

By default, MicroStrategy takes control of the navigation bar when MicroStrategy content is viewed in a mobile application. It puts the object name at the top of the bar and adds a Back button and other buttons. However, you can override this behavior by providing a custom title and setting the generic hidesBackButton property to YES.

The code snippets below illustrate how to suppress this default behavior and create a custom navigation bar that has only a custom title and no buttons.

  • When the application finishes launching, it invokes the didFinishLaunchingWithOptions method. In this method, you create the navigation controller and assign it to the window's root view controller.

    Copy
    - (BOOL)application:(UIApplication *)iApplication didFinishLaunchingWithOptions:(NSDictionary *)iLaunchOptions {
        ...
        self.navController = [[MyNavigationController alloc] init];   
        self.navController.delegate = self;    
        self.window.rootViewController =  self.navController;
        ...   
    }
  • In thewillShowViewControllerdelegate method, you hide the Back button and set up the custom  title.

    Copy
    - (void)navigationController:(MyNavigationController *)
       viewController.navigationItem.hidesBackButton = YES;
       viewController.navigationItem.title = self.navController.title;
    }

    If you want, you can also set up an image, add buttons, or do other customizations in the willShowViewController method.

  • In the setupNavigationControllerWithApplicationLauncher method, you set up connection information and the setting to suppress the navigation bar.

    Copy
    - (void) setupNavigationControllerWithApplicationLauncher: (
       [Generic setupConnectInfoFromPlist: @"ConnectionInfo.plist"];
       [Generic getSDKEnvSettings].isNavBarItemsSuppressed = YES;
    }
  • In the ViewDidLoad method of the view controller, you do additional setup after loading the view, typically from a nib. You load the MicroStrategy object to be displayed in into the MSTRObjectViewController and also set the view of the MSTRObjectViewController. You point to a specific document and tell the application to suppress the navigation bar. 

    Copy
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.mMicroStrategyVC = [[MSTRObjectViewController alloc]init]; //]WithMode:ObjectVCMode];
        [self.mMicroStrategyVC setNavToolbarSuppressed:YES]; 
        [self.mMicroStrategyVC loadWithObjectID: @"374377BE47BA3CE179B10AAF592782E7"
                                           type: ObjectTypeDocumentDefinition ];
           self.mMicroStrategyVC.view = self.mMicroStrategyView;
           [self.mMicroStrategyVC didMoveToParentViewController:self];
    }
  • In the ViewDidLoad method of the navigation controller, you push the view controller into the navigation controller. You use the appropriate nib file for initialization and provide the text for the title to be used in the custom navigation bar.

    Copy
    - (void)viewDidLoad {
        [super viewDidLoad];   
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            self.myViewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
        } else {
            self.myViewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
        }
        [self pushViewController:self.myViewController animated:NO];
        self.title = @"My Custom Title";
    }