How to add a view on top of a UIPopoverController

前端 未结 2 352
南旧
南旧 2021-01-03 08:13

I\'ve got an iPad app with a “drawer” table displayed in a popover. The user can tap-and-hold on an item in the drawer to drag that item out of it and into my main view. Tha

相关标签:
2条回答
  • 2021-01-03 08:44

    Got it. UIWindow works fine. Code:

    // when drag starts
    draggingView = [[UIWindow alloc] initWithFrame:CGRectMake(0,0,100,100)];
    draggingView.windowLevel = UIWindowLevelAlert;
    draggingView.center = [gestureRecognizer locationInView:self.view.window];
    [draggingView makeKeyAndVisible];
    
    // when drag ends
    [draggingView release];
    draggingView = nil;
    
    0 讨论(0)
  • 2021-01-03 08:57

    Adding the Swift Version:

        let windows: [UIWindow] = UIApplication.shared.windows
        let firstWindow: UIWindow = windows[0]
    
        firstWindow.addSubview(loadingView)
        firstWindow.bringSubview(toFront: loadingView)
    

    EDIT to admin: thanks for the review – deleted my other answer in duplicate How to show a UIView OVER a UIPopoverController

    0 讨论(0)
提交回复
热议问题