UISegmentedControl - 最后一段不容易选择

时间:2013-05-10 21:48:39

标签: ios objective-c uisegmentedcontrol

所以我使用的是一个UISegmented Control,显示为enter image description here

最后一段“5”难以用手指击打。我从模拟器中注意到使用光标,只有一半的片段会响应。半边右边的任何东西基本上都是一个死区。我不确定是什么导致了这一点,因为我将这个分段控件移到了顶部,它仍然做同样的事情。但是,如果我将分段控件移动到屏幕中心,则5段整个表面区域会响应触摸事件......

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

1 个答案:

答案 0 :(得分:1)

要查看代码可能重叠的内容,请添加此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];