0

It seems like you can access most views/windows in iOS, but I don't have much experience, so hoping someone can help.

In trying to resolve this issue, I have some ideas, but they will require me to get the UIView used for the little blue box displayed when a word will be autocorrected.

I think I need to start with something like this, but have no idea where to go from here:

-(void) scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSArray *windows = [UIApplication sharedApplication].windows;
    for (UIWindow *w in windows)
    {
    }
}

I'm adding this as a separate question because I can think of other reasons a person might want to access this (maybe change the color/style?). I understand it is part of the "system" and maybe not best practices to modify it, but I think it's probably okay as long as not a crucial part of your app, and you make your code pretty safe (i.e.-check pointers for nil, error on side of safety). In my case, for now, I just want to hide it, when it should be hidden (when scrolling).

Community
  • 1
  • 1
eselk
  • 6,764
  • 7
  • 60
  • 93

1 Answers1

0

Once I realized UIWindow was derived from UIView I came up with this possible answer, which seems to work so far:

-(void) walkViews:(UIView*)v
{
    NSString *className = NSStringFromClass([v class]);
    if([className isEqualToString:@"UIAutocorrectInlinePrompt"])
        v.hidden = YES;
    NSArray *subviews = v.subviews;
    for(UIView *sv in subviews)
        [self walkViews:sv];
}

-(void) scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSArray *windows = [UIApplication sharedApplication].windows;
    for (UIWindow *w in windows)
    {
        [self walkViews:w];
    }
}

Instead of having this code in a scroll event, you can put it wherever suits your needs. The main thing is that it walks all subviews looking for UIAutocorrectInlinePrompt. Instead of hiding it, you can do whatever is needed for your specific needs.

eselk
  • 6,764
  • 7
  • 60
  • 93