Iphone ipad第二启动屏幕
我想在我的应用程序中创建第二个启动屏幕。 我的想法是使用Iphone ipad第二启动屏幕,iphone,xcode,ipad,Iphone,Xcode,Ipad,我想在我的应用程序中创建第二个启动屏幕。 我的想法是使用default.png加载一个UIView,里面有一个全屏UIImageView 在viewDidLoad中,我考虑放置一个睡眠选项,然后加载真正的应用程序屏幕。 但是,当在viewDidLoad中调用我的函数时,什么也不会发生 看来我的超视界是空的。。。 下面是一段代码: if (self._pdfview == nil) { pdfview *videc = [[pdfview alloc]
default.png
加载一个UIView
,里面有一个全屏UIImageView
在viewDidLoad
中,我考虑放置一个睡眠选项,然后加载真正的应用程序屏幕。
但是,当在viewDidLoad
中调用我的函数时,什么也不会发生
看来我的超视界是空的。。。
下面是一段代码:
if (self._pdfview == nil)
{
pdfview *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];
窗口
在这一行之后为空,因此这可能是未加载其他视图的原因
我的问题是,如何创建第二个启动屏幕
或者三个起始屏幕,就像我在游戏中提到另一家公司一样。如果我理解正确,您的观点是,当您从某个控制器的
视图didload
执行上述功能时,窗口
为零,因此您的新视图(startscreen)不会添加到其中
一些意见:
窗口
为零,则self.view
是最上面的UIView;您可以尝试替换它,或者只需将视图添加到其中:
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];
}
[[UIApplication sharedApplication].keyWindow addSubview:newView];
[UIApplication sharedApplication].keyWindow;
rootViewController
(来自iOS 4.0)
或将newView作为子视图添加到其中:
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];
}
[[UIApplication sharedApplication].keyWindow addSubview:newView];
在第二种情况下,您可能应该删除以前添加到ui窗口的所有子视图。(在keyWindow.subview上迭代并调用removeFromSuperview
)
旧答案:
我认为您应该尝试将pdfview
作为子视图添加到当前视图中:
[currentView addSubview:videc];
或者到您称之为的窗口
:
[theWindow addSubview:pvidec];
并且,请将release
语句移动到`addSubview'之后,否则该视图将立即解除分配。mmm对于您的答案,加载任何视图都不是我的问题。问题是创建第二个startscreen,包含任何图片。我不确定我是否理解您的意思。要创建第二个startscreen,您需要加载一个图像或笔尖,并将其显示在当前视图的顶部。方法是使用addSubview
。在你的代码中,你加载videc
,但是你不做任何事情,也就是说,你不尝试显示它…我调用这个函数加载另一个xib。论坛不允许我发布代码:(但是当我从按钮调用它时,它根本不从viewdiload-(void)topdf2{if(self.\u pdfview==nil)工作){pdfview*videc=[[pdfview alloc]initWithNibName:@“pdfview”bundle:nil];self.\u pdfview=videc;[pdfview release];}//获取当前显示UIView*currentView=self.view的视图;//获取基础UIWindow或包含当前视图的视图UIView*theWindow=[currentView superview];