ios - UISegmentedControl - 最后一段不容易选择

标签 ios objective-c uisegmentedcontrol

所以我正在使用 UISegmented 控件,如图 enter image description here

最后一段“5”很难用我的手指敲击。我从使用光标的模拟器中注意到,大约只有一半的段会响应。半场右侧的任何区域基本上都是死区。我不确定是什么原因造成的,因为我已将此分段控件移至顶部,但它仍然执行相同的操作。但是,如果我将分段控件移至屏幕中心,则 5 段整个表面区域会响应触摸事件...

我不知道如何解决这个问题。

最佳答案

要查看哪些内容可能与您的代码重叠,请添加此 UIVIew 类别:

@interface UIView (Dumper_Private)

+ (void)appendView:(UIView *)v toStr:(NSMutableString *)str;

@end

@implementation UIView (Dumper_Private)

+ (void)appendView:(UIView *)a toStr:(NSMutableString *)str
{
    [str appendFormat:@"  %@: frame=%@ bounds=%@ layerFrame=%@ tag=%d userInteraction=%d alpha=%f hidden=%d\n", 
        NSStringFromClass([a class]),
        NSStringFromCGRect(a.frame),
        NSStringFromCGRect(a.bounds),
        NSStringFromCGRect(a.layer.frame),
        a.tag, 
        a.userInteractionEnabled,
        a.alpha,
        a.isHidden
        ];
}

@end

@implementation UIView (Dumper)

+ (void)dumpSuperviews:(UIView *)v msg:(NSString *)msg
{
    NSMutableString *str = [NSMutableString stringWithCapacity:256];

    while(v) {
        [self appendView:v toStr:str];
        v = v.superview;
    }
    [str appendString:@"\n"];

    NSLog(@"%@:\n%@", msg, str);
}

+ (void)dumpSubviews:(UIView *)v msg:(NSString *)msg
{
    NSMutableString *str = [NSMutableString stringWithCapacity:256];

    if(v) [self appendView:v toStr:str];
    for(UIView *a in v.subviews) {
        [self appendView:a toStr:str];
    }
    [str appendString:@"\n"];

    NSLog(@"%@:\n%@", msg, str);
}

@end

并调用[UIView dumpSuperviews:theSegmentedControl];

关于ios - UISegmentedControl - 最后一段不容易选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16491273/

相关文章:

ios - iPhone - UILabel 留在 UITableViewCell 之外

ios - 是否可以使用大小类来调整 UISegmentedControl 对象的文本大小?

ios - 如何使用 Xcode Storyboards 进行项目协作?

objective-c - 在 xcode 中以 MM/dd/yyyy 格式转换日期?

ios - xcode 7.1 swift 框架应用程序构建但不存档

objective-c - iOS:UITabBarController - 项 View 的延迟加载

ios - 将 UIView 坐标从纵向转换为横向,反之亦然

在 id 的对象上找不到 iOS SpringBoard 属性 badgeNumberOrString

ios - UISegmentedControl subview 未出现

ios - 对 UISegmentedControl 图像进行动画处理