AOY
AOY

Reputation: 355

View overlapping nofication

I would be grateful if anyone could tell me how can I find out that one of my subviews is overlapped by anything (I mean some alerts or something like that)

Upvotes: 0

Views: 191

Answers (2)

Ashish P.
Ashish P.

Reputation: 858

Use following code..

- (void)checkAnyViewOverlappingViewFrame:(UIView*)view topLevelView:(UIView *)toplevelview viewToSearch:(UIView*)viewtosearch {

    // Get the subviews of the view
    NSArray *subviews = [viewtosearch subviews];

    // Return if there are no subviews
    if ([subviews count] == 0) return; // COUNT CHECK LINE

    for (UIView *subview in subviews) {

        CGRect frameRelativeToParent = [subview convertRect:subview.bounds
                                                       toView:toplevelview];

        if (CGRectIntersectsRect(view.frame, frameRelativeToParent) && view.layer.zPosition < subview.layer.zPosition) {

            NSLog(@"Overlapping view: %@", subview);
        }

        [self checkAnyViewOverlappingViewFrame:view topLevelView:toplevelview viewToSearch:subview];
    }
}

Here view is your subviews to check. In toplevelview pass self.view which parent view of all views. In viewtosearch pass self.view

Upvotes: 1

iAnurag
iAnurag

Reputation: 9356

you can view itself in xcode while running the app. Follow these steps.

  1. Run the app in simulator.
  2. Select xcode window and Go to debug from top menu bar and select Capture view Hierarchy

enter image description here

  1. Here you can see your complete view structure.

Upvotes: 2

Related Questions