Ios input panel button for modal viewing

I am using idev-recipes / RaisedCenterTabBar and I want the modal view to be called from the center button, not from the camera.

The code is here: https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar

Any ideas on how to do this?

+6
source share
5 answers

I would create my own subclass of UITabBarController and then add this method:

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { } 

You can specify which item has been selected, and then create an instance of modal VC inside.

+2
source

There is a better approach to implementing this decision. And much easier.

What I understand using this methodology: https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar are weird things when you try to hide the tab bar. Therefore, the best solution I found for me (the same as you) is here: http://www.lantean.co/display-a-modal-uiviewcontroller-when-a-uitabbaritem-is-pressed/

There is no need to do anything else. Just ignore the view controller that the UITabBarItem is associated with and represents your modal view! It's all!

+4
source

Perhaps you could just use UITabBarDelegate with a method
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
.
The method is sent to the delegate when someone clicks a button on the tab bar. There you can check if it was the right button, and then create an instance of the modal controller.

0
source

Either with a subclass or with the help of a delegate, you can simply check whether the item you have selected is selected, and if so, in the tab bar, select the item that was previously selected, and then present your model view controller. Since you will be doing this in the same RunLoop source that the original selection has occurred, the tab selection will be effectively canceled without switching to the average VC.

0
source

According to the sample code provided by you => https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar

The central button with the tabs raised is UIButton, so just set the action of this button, as it is in the BaseViewController.m class

 [button addTarget:self action:@selector(showmodalview) forControlEvents:UIControlEventTouchUpInside]; 

and then in the showmodalview method write this code =>

 -(void)showmodalview { UIViewController *view1=[[UIViewController alloc] init]; // you can use any view controller instance you want ,this is just the example. [self presentModalViewController:view1 animated:YES]; } 
0
source

Source: https://habr.com/ru/post/915050/


All Articles