문제

I am trying to add a UIView to UIWindow using the appDelegate I am using this code:

NSArray *myViewArray = [[NSBundle mainBundle] loadNibNamed:@"View" owner:self options:nil];

UIView *myView = myViewArray[0];

UIWindow *window = [[[UIApplication sharedApplication] delegate] window];

myView.frame = CGRectMake(0, 0, 258, 564);
[myView setTag:100];
[window addSubview:myView];

However this doesn't work. If I add it to my self.view it works fine. However, I want this view to be onto of all other views when it appears.

What am I doing wrong here?

Edit

I used code from my last SO question: How to add a UIImage below UIBarButton item

There it worked fine, no problems.

However in this new project which only has a viewDidLoad method and one controller its not working.

도움이 되었습니까?

해결책

Make sure you are adding the subview after you've initialised your window, set its rootViewController and called makeKeyAndVisible.

다른 팁

try using [window bringSubViewToFront:myView];

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top