objective-c - 如何以编程方式移动到另一个 UIViewController?
<p><p>我目前正在执行 <code>CurrentViewController</code> 中的一个方法,当我到达当前正在执行的方法的结尾</p>
<p><strong>CurrentViewController.m</strong></p>
<pre><code>-(void)methodExecutingOnCurrentViewController
{
//some code..
// what method do I call in order to load and move to my FirstViewController at this point?
// do I first initialize an instance of the ViewController I want to move to?
UIViewController *firstViewController = [ init];
// but now how do I actually move to this instance I've just created?
// I couldn't find the appropriate method in the class reference documentation
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>看看<code>- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated</code> <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html" rel="noreferrer noopener nofollow">Doc</a> .</p>
<p>还有许多其他方法可以完成您正在寻找的事情,您是否使用导航 Controller ?然后 <code>- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated</code> 就是你想要的。您也可以将该 Controller 的 View 作为 subview 添加到当前的 viewController。</p></p>
<p style="font-size: 20px;">关于objective-c - 如何以编程方式移动到另一个 UIViewController?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/12272710/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/12272710/
</a>
</p>
页:
[1]