这是我的代码
- (NSDictionary*)parseURLParams:(Nsstring *)query{ NSArray *pairs = [query componentsSeparatedByString:@"&"]; NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; for (Nsstring *pair in pairs){ NSArray *kv = [pair componentsSeparatedByString:@"="]; Nsstring *val = [[kv objectAtIndex:1] stringByReplacingPercentEscapesUsingEnCoding:NSUTF8StringEnCoding]; [params setobject:val forKey:[kv objectAtIndex:0]];}return params;}- (voID)alertVIEw:(UIAlertVIEw *)alertVIEw clickedbuttonAtIndex:(NSInteger)buttonIndex{ Nsstring *Title = [alertVIEw buttonTitleAtIndex:buttonIndex]; if([Title isEqualToString:@"Send Challenge"]) { [FBWebDialogs presentRequestsDialogModallyWithSession:nil message:[Nsstring stringWithFormat:@"I just scored %i points on this great game,called SumsUp. can you beat it?!",gamescore] Title:nil parameters:nil handler:^(FBWebDialogResult result,NSURL *resultURL,NSError *error) { if (error) { // Error launching the dialog or sending the request. NSLog(@"Error sending request."); } else { if (result == FBWebDialogResultDialogNotCompleted) { // User clicked the "x" icon NSLog(@"User canceled request."); } else { // Handle the send request callback NSDictionary *urlParams = [self parseURLParams:[resultURL query]]; if (![urlParams valueForKey:@"request"]) { // User clicked the Cancel button NSLog(@"User canceled request."); } else { // User clicked the Send button Nsstring *requestID = [urlParams valueForKey:@"request"]; NSLog(@"Request ID: %@",requestID); } } } }]; }
我在P-List中有自定义URL设置.
在我的app委托中,我有:
- (BOol)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(Nsstring *)sourceApplication annotation:(ID)annotation{ UIAlertVIEw *alertVIEw; Nsstring *text = [Nsstring stringWithFormat: @"url recIEved: %@",url]; alertVIEw = [[UIAlertVIEw alloc] initWithTitle:@"" message:text delegate:nil cancelbuttonTitle:@"OK" otherbuttonTitles:nil]; [alertVIEw show]; return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication withSession:[PFFacebookUtils session]];}
我希望这是有道理的,有人可以帮助我.如果需要更多信息,请告诉我?
谢谢格雷厄姆
解决方法 我在ios v.9.xx上遇到了自定义URL方案的问题.当我尝试通过App打开Youtube URL时.当我浏览网络时,我发现了一个有趣的事实.iOS 9要求您的应用程序预先注册它打算调用的应用程序方案.
>打开YourApp-Info.pList文件并添加密钥LSApplicationQuerIEsSchemes.
>在LSApplicationQuerIEsSchemes下列出项目,添加一个
具有值youtube的新项目(在我的情况下).
<key>LSApplicationQuerIEsSchemes</key><array> <string>youtube</string></array>总结
以上是内存溢出为你收集整理的iOS自定义网址方案全部内容,希望文章能够帮你解决iOS自定义网址方案所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)