Alan
Alan

Reputation: 9481

UISegmentedControl - Last Segment does not select easily

So I am using a UISegmented Control as shownenter image description here

The last segment the "5" is incredibly hard to hit with my finger. I noticed from the simulator using a cursor that about only half of the segment will respond. Anything to the right of the half is basically a deadzone. I am not sure what's causing this as I have moved this segmented control to the top and it still does the same thing. However, if I moved the segmented control to center of the screen, the 5 Segment entire surface area responds to touch events...

I'm not sure how to fix this.

Upvotes: 0

Views: 259

Answers (1)

David Hoerl
David Hoerl

Reputation: 41652

To see what might be overlapping your code, add this UIVIew Category:

@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

and call [UIView dumpSuperviews:theSegmentedControl];

Upvotes: 1

Related Questions