iphone - 如何获取uislider指向区域?

标签 iphone objective-c ios uislider

我的 uislider 顶部有 6 个选项卡,请参阅 image .

现在我想获取 slider 指向的选项卡。如果我们移动 slider 。

所有选项卡都可以通过拖动和放置来重新排列,因此如果 tab1 移动到 tab5 的位置并且 slider 位于 tab5(倒数第二个位置)(这是 tab1 的新位置),它应该显示 tab1 值而不是 tab5 值。

- (void)addTab:(UIViewController *)viewController {
if ([self.delegate respondsToSelector:@selector(willShowTab:)]) {
    [self.delegate willShowTab:viewController];
}

if (![self.childViewControllers containsObject:viewController] && self.count < self.maxCount - 1) {
    [self addChildViewController:viewController];
    viewController.view.frame = _contentFrame;

    if (_toobarVisible)
        [self.toolbar setItems:viewController.toolbarItems animated:YES];

    // Add tab selects automatically the new tab
    [UIView transitionWithView:self.view
                      duration:kAddTabDuration
                       options:UIViewAnimationOptionAllowAnimatedContent
                    animations:^{
                        [self.tabsView addTab:viewController.title];

                        if (self.currentViewController) {
                            [self.currentViewController viewWillDisappear:YES];
                            [self.currentViewController.view removeFromSuperview];
                            [self.currentViewController viewDidDisappear:YES];
                        }

                        [self.view addSubview:viewController.view];
                    }
                    completion:^(BOOL finished){
                        [viewController didMoveToParentViewController:self];
                        _currentViewController = viewController;
                    }];
}

请提供我的代码片段。

感谢您的帮助。

谢谢,

最佳答案

理想情况下,如果所有选项卡的宽度相同,那么您只需找出 slider 当前位于总宽度的哪个部分,然后选择该索引处的选项卡。否则,您将必须遍历选项卡以找到其水平边界,以确定 slider 正在选择哪个选项卡

关于iphone - 如何获取uislider指向区域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11033724/

相关文章:

iphone - 如何将 double[][] 存储到文件或 iOS 中持久存在的任何内容中?

iPhone 导航栏字体

ios - Xcode 6.3 的 NSParameterAssert 编译错误

iphone - 将 NSstring 日期转换为 UTC 日期

objective-c - 在 swift 中从前缀 header 引用类定义

ios - Swift 协议(protocol)泛型错误(ORM 实现)

ios - Swift 中 UIViewController 所需的构造函数

iphone - 复制dylib

ios - 无法在 iOS Swift 中使用 Assets 运行动画

ios - 如何使用 UICollectionViewController 设置具有多个部分的 1 标题