2013-11-21 85 views
1

代码工作正常与其他环节而不是机智Youtube链接特别是当链接包含视频ID ......无法发送YouTube视频链接,以什么应用,因为短信

NSString*str=[NSString stringWithFormat:@"http://youtube.com/watch?v=%@",myVideoId]; 

    NSString*Wastring2=[ NSString stringWithFormat:@"whatsapp://send?text=%@",str]; 

    NSURL *whatsappURL = [NSURL URLWithString:Wastring2]; 

    if ([[UIApplication sharedApplication] canOpenURL: [whatsappURL absoluteURL]]) { 
     [[UIApplication sharedApplication] openURL: [whatsappURL absoluteURL]]; 
    } 

谢谢。

回答

0

尝试编码您的YouTube网址。

NSString*str=[NSString stringWithFormat:@"http://youtube.com/watch?v%3D%@",myVideoId]; 
+0

thanx的答案... BT无法发送机智ID http://youtube.com/watch?v=id – sankalp

+0

什么不工作是什么呢? – slecorne

+0

“youtube.com/watch?v=id”如果我删除“=”符号,那么它的工作原理 – sankalp

0

好吧,我测试了Youtube链接,现在它的代码工作下面你只需要个逃生?v=添加到?v%%3D

要小心,有必须是两个%%逃避串手动

NSString*str=[NSString stringWithFormat:@"http://youtube.com/watch?v%%3D%@",myVideoID]; 
str=[NSString stringWithFormat:@"whatsapp://send?text=%@",str]; 
NSURL *whatsappURL = [NSURL URLWithString:str]; 
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { 
    [[UIApplication sharedApplication] openURL: whatsappURL]; 
} 
+0

我已经做了这个,但没有工作.... thanx – sankalp