V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
daiyuechuan
V2EX  ›  iDev

在处理“登陆按钮”的时候,大家用的是哪种 segue 来切换场景呢?

  •  
  •   daiyuechuan ·
    CrazyNeil · 2015-04-12 09:11:05 +08:00 · 2210 次点击
    这是一个创建于 3304 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我一直觉得我的segue有点问题,我用的是viewCronller载入完成后检查当前用户的合法性,然后用instantiateViewControllerWithIdentifier 跳转到别的视图,有没有办法呢,如果直接从按钮建立一个到视图的@IBAction 我不知道如何先判断,再传递,系统默认是一点按钮直接就跳转了。。

    ```
    //检查用户是否已经登录,如果已经登录,直接跳转到主控板
    override func viewDidAppear(animated: Bool){

    var currentUser = PFUser.currentUser()
    if currentUser != nil {
    println("\(currentUser)")
    var sb = UIStoryboard(name: "Main", bundle:nil)
    var vc = sb.instantiateViewControllerWithIdentifier("mainBoardEnter") as UITabBarController
    self.presentViewController(vc, animated:true, completion:nil)
    }
    }
    ```
    2 条回复    2015-04-13 12:21:38 +08:00
    Madimo
        1
    Madimo  
       2015-04-12 23:45:07 +08:00 via iPhone
    检查当前用户的合法性可以放在 AppDelegate 的 ApplicationDidFinishLaunchWithOptions 那个方法里啊,然后直接改 window 的 rootViewController。
    第二个问题,正确姿势是在 Storyboard 中添加一个 ViewController 到 ViewController 的 Segue,然后设定 Segue 的 identifier,然后在按钮的 TouchUpInside 事件响应方法中,需要跳转时用 self.performForSegueWithIdentifier() 来跳转。
    wezzard
        2
    wezzard  
       2015-04-13 12:21:38 +08:00
    Segue sucks. You need to do it programmatically.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5344 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:02 · PVG 15:02 · LAX 00:02 · JFK 03:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.