Search code examples
iphoneiosuiwindow

How to add common UIButton at the bottom on my all view instead of tabsview controller in iphone?


I want to put UIbutton at bottom which should be displayed on my all view like tabBar and onclick of that UIButton I want open the menu view, How can achieve this feature, I tried lot for this and also lot of google search for it, but not mention the way to achieve this properly, So please suggest me the the proper way to achieve this

This image contain at bottom one 'Team' button, onclick of that 'Team' the menu view should open look next screen shot for that

The black view contaning menu should open


Solution

  • I have done this before by adding a button in the Appdelegate class. I don't know whether it's a correct approach or not, but it's working.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        viewController = [[SUSAViewController alloc] initWithNibName:@"SUSAViewController" bundle:nil];
    
        nav=[[UINavigationController alloc]initWithRootViewController:viewController];
        self.window.rootViewController = nav;
    
        UIButton *mybtn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
        mybtn.frame=CGRectMake(40, 200, 200, 200);
        [mybtn setTitle:@"My Button" forState:UIControlStateNormal];
    
        [nav.view addSubview:mybtn];
    
        [self.window makeKeyAndVisible];
    
        return YES;
    }
    

    If you are not using NavigationController then simply add [self.window addSubview:mybtn]; Hope it will work for you.