如何在viewDidLoad中加载视图? [英] How to Load a View in viewDidLoad?
问题描述
我想在程序的开头加载第二个View.我认为,viewDidLoad方法将是正确的方法.问题是它不起作用.
I want to load a second View at the beginning of a program. I thought, that the viewDidLoad-methode would be the right method. The problem is that it doesn't work.
之所以要在viewDidLoad方法中加载视图,是因为在新设备(iPad)上可以在其他视图上加载视图.
The reason why I want to load a view in the viewDidLoad-method is that it is possible on a new device (iPad) to load a view over the other view.
我该怎么做?我试过了,但是没用:
How can I make it? I tried this, but it doesn't work:
- (void)viewDidLoad {
StartViewController * start = [[StartViewController alloc]initWithNibName:nil bundle:nil];
start.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
start.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:start animated:YES];
}
我尝试了addSubview,它可以工作,但是后来我没有很好的过渡.任何想法?我也尝试过awakeFromNib.同样,这也不是关于iPad的问题,因此我不会破坏nda.这是一个普遍的问题,如何在viewDidLoad方法(或其他方法)中加载新视图.
I tried addSubview and it works, but then I don´t have the nice transition. Any idea? I also tried awakeFromNib. Also this is not a question about the iPad, so I don't break the nda. It is a general question, how to load a new view in the viewDidLoad-method (or an other method).
推荐答案
这适用于viewDidAppear,而不适用于viewDidLoad.该视图需要出现才能在其前面显示另一个视图.除此之外,我在某些项目中使用了相同的代码,您所做的描述
This works with viewDidAppear, not viewDidLoad. The view needs to have appeared for another to show up in front of it. Aside from that, I have the same code in some of my projects, does what you describe
这篇关于如何在viewDidLoad中加载视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!