How can I use a custom UIWindow in order to override the sendEvent function?

Viewed 67

SNWindow is a custom class I made with a custom delegate which overrides the sendEvent function.

In previous versions of iOS (when there was no SceneDelegate) I used to insert this code in the AppDelegate.h:

@property (strong, nonatomic) SNWindow *window;

This code in the AppDelegate.m:

- (SNWindow *)window {
    
    static SNWindow *window = nil;
    
    if (!window) {
        
        window = [[SNWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    }
    
    return window;
}

And this code in the ViewController.m:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    appDelegate.window.delegate = self;

    appDelegate.window.view = self.view;
}

Unfortunately, this doesn't work anymore. I tried changing the UIWindow of SceneDelegate but nothing loads on screen, just a black screen.

0 Answers
Related