iosobjective-ccydia-substratelogos

UIWindow keyWindow changed notification


I'm creating a jailbreak tweak that adds a view to the UIWindow of whatever the current keyWindow is. The problem is that whenever the keyWindow changes the view gets removed.

I'm using this

%hook SBApplication
-(void)willActivate {
    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0,320,53)];
    view.backgroundColor = [UIColor greenColor];
    [window addSubview:view];
}
%end

is there another method that is better to use here or is there a notification that is sent whenever the window changes?


Solution

  • Figured it out!

    Method called when a keyWindow is changed is in UIWindow and the method is

    -(void)makeKeyWindow
    

    just hook that and then add your subview!