ipad second start screen
i like to create a second starting screen in my app.
My Idea is to use the default.png
and load an UIView
with an fullscreen UIImageView
inside.
In viewDidLoad
i thought about placing a sleep option and after this load the real app screen.
But also when my function is called in viewDidLoad
, nothing happens.
Seems my superview is empty... Here is a piece of code:
if (self._pdfview == nil)
{
pdfv开发者_运维知识库iew *videc = [[pdfview alloc]
initWithNibName:@"pdfview" bundle:nil];
self._pdfview = videc;
[pdfview release];
}
// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];
theWindow
is empty after this line so that might be the reason why the other view is not loaded.
So my question, how do i create a second starting screen ?
Or three starting screens, like in games when i like to mention another company.
If I understand correctly, your point is that when your function above is executed from viewDidLoad
of some controller, theWindow
is nil, so your new view (startscreen) is not added to it.
A few observations:
if
theWindow
is nil, thenself.view
is the topmost UIView; you can try and replace it, or simply add your view to it:UIView *currentView = self.view; // get the the underlying UIWindow, or the view containing the current view UIView *theWindow = [currentView superview]; UIView *newView = _pdfview.view; if (theWindow) { [currentView removeFromSuperview]; [theWindow addSubview:newView]; } else { self.view = newView; //-- or: [self.view addSubview:newView]; }
if you want to get the UIWindow of your app (which seems what you are trying to do), you can do:
[UIApplication sharedApplication].keyWindow;
and from there you can either set the rootViewController
(from iOS 4.0)
[UIApplication sharedApplication].keyWindow.rootViewController = ...;
or add newView as a subview to it:
[[UIApplication sharedApplication].keyWindow addSubview:newView];
in the second case, you should possibly remove all subviews
previously added to the UIWindow
. (Iterate on keyWindow.subviews and call removeFromSuperview
).
OLD ANSWER:
I think that you should try and add your pdfview
as a subview to the current view:
[currentView addSubview:videc];
or to what you call theWindow
:
[theWindow addSubview:pvidec];
and, please, move the release
statement after the `addSubview, otherwise the view will be deallocated immediately.
精彩评论