编辑:如何在此存储库中添加登录View Controller:https://github.com/gazolla/MapTable-Swift
我想获取AppDelagate中的内容,并使用情节提要直观地创建它,以便它1)当我编译代码并没有立即调用2)因此,随着故事板的发展,我可以做其他事情。我添加了新的Storyboard,并创建了带有嵌入式NavigationController的UIViewController,但无法创建MyCustomClassViewController的自定义。
这是AppDelagate在下面使用的代码。我如何使用情节提要模拟此内容?
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
// Override point for customization after application launch.
let v = Venue(aIdent:1, aName: "", aAddress: "", aCity: "", aCategoryName: "", aLat: "", aLng: "")
var venuesArr : Array<Venue> = []
venuesArr.append(v)
let vtv:TableMapViewController = TableMapViewController(frame: self.window?.frame as CGRect!)
vtv.setVenueCollection(venuesArr)
let nav:UINavigationController = UINavigationController(rootViewController: vtv)
self.window!.rootViewController = nav
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.makeKeyAndVisible()
return true
}
如果使用情节提要,并且导航控制器是应用程序的初衷,则可以直接从下面获得它。
let navigation = self.window!.rootViewController as! UINavigationController
如果要显式设置,则可以执行以下操作。
let nav = runTestStoryBoard.instantiateViewControllerWithIdentifier("UINavigationController") as! UINavigationController// Give navigation controller identifier as UINavigationController in storyboard.
let abc = runTestStoryBoard.instantiateViewControllerWithIdentifier("MyCustomViewController") as! MyCustomViewController// Give this view controller identifier as MyCustomViewController in storyboard.
如果要使用abc作为根视图控制器,则可以执行以下操作。
nav.viewControllers = [abc
这里是放置视图控制器(您的登录视图控制器)的解决方案
changeRootViewController()
。此方法将在appdelegate类中。func changeRootViewController()
,您将在其中将窗口的根视图控制器从登录视图控制器更改为导航控制器。现在,您的应用程序将使流动的acress scrrens变得平滑。