我正在使用idev-recipes/RaisedCenterTabBar,并希望从中心按钮调用模态视图,而不是相机。
代码在这里: https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar 你有什么想法来实现这个功能吗?
代码在这里: https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar 你有什么想法来实现这个功能吗?
我会创建你自己的UITabBarController子类并添加这个方法:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
}
您将能够确定选择了哪个项目,然后在其中实例化一个模态VC。
tabBarController(_:shouldSelectViewController:)
代替。 - ma11hew28你可以使用UITabBarDelegate,并结合
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
方法。
当有人在选项卡栏中按下按钮时,该方法将发送到委托。在这里,您可以检查是否是正确的按钮,然后实例化模态视图控制器。
[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];
}
UITabBar
上的按钮来弹出模态视图。您需要让您的问题更加具体。 - Shaggy Frog