Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如果输入一个给定的ViewController,如何删除选项卡栏_Ios_Iphone_Swift - Fatal编程技术网

Ios 如果输入一个给定的ViewController,如何删除选项卡栏

Ios 如果输入一个给定的ViewController,如何删除选项卡栏,ios,iphone,swift,Ios,Iphone,Swift,设置: 假设我有2个TableViewController(都在它们自己的NavigationController中),它们相应地包含TypeA和B项 在任何TableView中,如果我点击“+”按钮,它将切换到一个Add[?]ItemViewController(“?”是项的类型:a或B)。因此通常,即使我已经在AddView中,我也可以通过点击选项卡栏图标切换到另一个视图,对吗 那么,如果用户已经输入了一个AddView,我如何禁止用户切换呢 是否使用Swift代码?或者只是改变故事板的结构

设置:

假设我有2个TableViewController(都在它们自己的NavigationController中),它们相应地包含TypeA和B项

在任何TableView中,如果我点击“+”按钮,它将切换到一个Add[?]ItemViewController(“?”是项的类型:a或B)。因此通常,即使我已经在AddView中,我也可以通过点击选项卡栏图标切换到另一个视图,对吗

那么,如果用户已经输入了一个AddView,我如何禁止用户切换呢

是否使用Swift代码?或者只是改变故事板的结构

以下是Main.storyboard的结构:

我们在应用程序中做了完全相同的操作。隐藏默认值的步骤 TabBar,只需在 父视图控制器(或应用程序中的每个视图控制器)

另一个解决方案 您还可以隐藏选项卡栏

// pass a param to describe the state change, an animated flag and a completion block matching UIView animations completion 
- (void)setTabBarVisible:(BOOL)visible animated:(BOOL)animated completion:(void (^)(BOOL))completion {

    // bail if the current state matches the desired state
    if ([self tabBarIsVisible] == visible) return;

    // get a frame calculation ready
    CGRect frame = self.tabBarController.tabBar.frame;
    CGFloat height = frame.size.height;
    CGFloat offsetY = (visible)? -height : height;

    // zero duration means no animation
    CGFloat duration = (animated)? 0.3 : 0.0;

    [UIView animateWithDuration:duration animations:^{
        self.tabBarController.tabBar.frame = CGRectOffset(frame, 0, offsetY);
    } completion:completion];
}

// know the current state
- (BOOL)tabBarIsVisible {
    return self.tabBarController.tabBar.frame.origin.y < CGRectGetMaxY(self.view.frame);
}

// illustration of a call to toggle current state
- (IBAction)pressedButton:(id)sender {

    [self setTabBarVisible:![self tabBarIsVisible] animated:YES completion:^(BOOL finished) {
        NSLog(@"finished");
    }];
}

我已经补充了答案,如果有帮助,请投票表决
// pass a param to describe the state change, an animated flag and a completion block matching UIView animations completion 
- (void)setTabBarVisible:(BOOL)visible animated:(BOOL)animated completion:(void (^)(BOOL))completion {

    // bail if the current state matches the desired state
    if ([self tabBarIsVisible] == visible) return;

    // get a frame calculation ready
    CGRect frame = self.tabBarController.tabBar.frame;
    CGFloat height = frame.size.height;
    CGFloat offsetY = (visible)? -height : height;

    // zero duration means no animation
    CGFloat duration = (animated)? 0.3 : 0.0;

    [UIView animateWithDuration:duration animations:^{
        self.tabBarController.tabBar.frame = CGRectOffset(frame, 0, offsetY);
    } completion:completion];
}

// know the current state
- (BOOL)tabBarIsVisible {
    return self.tabBarController.tabBar.frame.origin.y < CGRectGetMaxY(self.view.frame);
}

// illustration of a call to toggle current state
- (IBAction)pressedButton:(id)sender {

    [self setTabBarVisible:![self tabBarIsVisible] animated:YES completion:^(BOOL finished) {
        NSLog(@"finished");
    }];
}
DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.hidesBottomBarWhenPushed = YES;
[[self navigationController] pushViewController:detailViewController animated:YES];