6

我正在使用 idev-recipes/RaisedCenterTabBar 并且我想要从中心按钮调用的模态视图,而不是相机。

代码在这里: https ://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar

关于如何使它工作的任何想法?

4

5 回答 5

4

为了实现这一目标,有更好的方法可以遵循。而且容易得多。

我通过使用这种方法实现的理解:https ://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar是当你试图隐藏标签栏时发生了奇怪的事情。所以我为我找到的最好的解决方案(和你做的一样)在这里:http ://www.lantean.co/display-a-modal-uiviewcontroller-when-a-uitabbaritem-is-pressed/

没有必要做任何其他事情。只需忽略与 UITabBarItem 关联的视图控制器并呈现您的模态视图!就这样!

于 2014-01-30T16:09:03.887 回答
2

我将创建您自己的 UITabBarController 子类,然后添加此方法:

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

}

您将能够知道选择了哪个项目,然后在其中实例化一个模态 VC。

于 2012-05-07T01:39:28.557 回答
0

可能你可以只使用UITabBarDelegate,该
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
方法。
当有人按下选项卡栏中的按钮时,该方法将发送给委托人。在那里你可以检查它是否是正确的按钮,然后实例化模态视图控制器。

于 2012-05-15T15:03:06.507 回答
0

通过子类化或使用委托,您可以简单地检查所选项目是否是您的中间按钮,如果是,让标签栏选择先前选择的项目,然后显示您的模型视图控制器。由于您将在原始选择发生的同一 RunLoop 源中执行此操作,因此选项卡选择将有效地撤消,而无需切换到中间 VC。

于 2012-05-16T13:51:04.200 回答
0

根据您提供的代码示例 => https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar

中央凸起的选项卡按钮是一个 UIButton,因此只需在 BaseViewController.m 类中设置该按钮的操作即可

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

然后在 showmodalview 方法中编写此代码=>

-(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];
}
于 2012-05-19T12:20:43.653 回答