Nicolò Ciraci
Nicolò Ciraci

Reputation: 678

Add UIView to Application at runtime

I should add a UIView to an application, I use:

UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[window addSubview:view];

But it only work on SpringBoard. Have anyone an idea?

Upvotes: 0

Views: 83

Answers (1)

Ole Begemann
Ole Begemann

Reputation: 135588

There is nothing wrong with your code and it will work. If it doesn't, view might be nil or the view's frame might not be set correctly.

Normally, you would use a view controller and, rather than adding views directly to the window, you would add them to the view controller's view.

Upvotes: 1

Related Questions