重定向到另一个视图控制器 [英] Redirect to another view controller

查看:68
本文介绍了重定向到另一个视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 iPhone 和 iPad 开发 iOS 应用.我有两个故事板文件,称为:Main_iPhone 和 Main_iPad.我在这些故事板中制作了一个登录屏幕,并设置了一个 LoginViewController.成功登录后,我想将用户重定向到 Main_iPhone 或 Main_iPad 中的另一个屏幕.我将此屏幕命名为 Dashboard,并在 Identity Inspector 中命名为自定义类 DashboardViewController.我已经创建了这个文件.

I am developing an iOS app for iPhone and iPad. I have two storyboard files, called: Main_iPhone and Main_iPad. I have made a loginscreen in these storyboards and I have set up a LoginViewController. After a succesfull login, I want to redirect the user to another screen in Main_iPhone or Main_iPad. I gave this screen the name Dashboard and in the Identity Inspector the custom class DashboardViewController. I have created this file.

我正在 Xcode 5 中为 iOS 7 开发

I'm developing for iOS 7 in Xcode 5

如何将用户重定向到我的信息中心?

How can I redirect the user to my dashboard?

推荐答案

有几种方法可以做到.首先是创建 DashboardViewController 并将其呈现给视图层次结构:

There is a few way you can do it. First is create DashboardViewController and present it to view hierarchy:

DashboardViewController *vc = [[DashboardViewController alloc] init];
[self presentViewController:vc animated:YES completion:nil];

另一个是在情节提要中从登录到仪表板创建转场,当您想重定向时,只需调用:

Another one is create segue in storyboard from Login to Dashboard and when you want to redirect just call:

[self performSegueWithIdentifier:@"SEGUE_IDENTIFIRE" sender:nil];

SEGUE_IDENTIFIRE 是您需要在故事板中设置的转场名称.

SEGUE_IDENTIFIRE is a segue name you need to set up in storyboard.

这篇关于重定向到另一个视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆