How to load view in appdelegate?
I am checking internet connection availability in application delegate. But instead of displaying alert view for no internet connection, i need to load a view or addsubview to the application. Also i need to remove that view in internet connectio开发者_C百科n available.
[window addSubView:errorconncting.view];
[errorconnecting removeFromsuperView];
This one is not working.
Thank You.
It is possible that you connected the main view to the window in the Interface Builder, this will override your own settings. The best approach would be to have a default view in the NIB, then depending on the internet connection add the appropriate view to this base / default view.
If Internet connection is not there
[self.view removeFromSuperView];
errorconnectingClassObject errorconncting = [errorconnectingClassObject alloc]initWithNibName:@"" options:nil];
[window addSubView: errorconncting.view];
instead of
[errorconnecting removeFromsuperView];
it should be
[errorconnecting.view removeFromsuperView];
You can add as many subviews to window. So whenever you have to show a new view, first try adding it in window as subview, see if it works.
精彩评论