2017-09-16 1 views
0

は、今私はあなたが別のモバイルアプリケーション(テストされていない)からのInstagramを起動するには、このようなものを使用することができ、完全に承知している他のアプリによって起動する:私は何

var instagramHooks = "instagram://user?username=johndoe" 
    var instagramUrl = NSURL(string: instagramHooks) 
    if UIApplication.sharedApplication().canOpenURL(instagramUrl!) { 
     UIApplication.sharedApplication().openURL(instagramUrl!) 
    } 
    else { 
     //redirect to safari because the user doesn't have Instagram 
     UIApplication.sharedApplication().openURL(NSURL(string: "http://instagram.com/")!) 
    } 

興味があるのは、モバイルアプリケーション内の特定のページに直接移動するURLを作成することです。 instagram://user?username=johndoe は、アプリケーションを起動した後、johndoeのプロファイルページに移動します。このようなリンクを作成するにはどうすればよいですか?

答えて

0

これを実現するには、Compassを使用することをおすすめします。コンパス付き

あなたはこの

Navigator.handle = { [weak self] location in 
    let arguments = location.arguments 

    let rootController = self?.window.rootViewController as? UINavigationController 

    switch location.path { 
    case "profile:{username}": 
     let profileController = ProfileController(title: arguments["username"]) 
     rootController?.pushViewController(profileController, animated: true) 
    case "login:{username}": 
     let loginController = LoginController(title: arguments["username"]) 
     rootController?.pushViewController(loginController, animated: true) 
    case "logout": 
     self?.clearLoginSession() 
     self?.switchToLoginScreen() 
    default: 
     break 
    } 
} 
ようにそれを行うことができます