Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在nsstring中提供超链接,以便在fb中共享?_Ios_Objective C_Hyperlink_Nsstring - Fatal编程技术网

Ios 如何在nsstring中提供超链接,以便在fb中共享?

Ios 如何在nsstring中提供超链接,以便在fb中共享?,ios,objective-c,hyperlink,nsstring,Ios,Objective C,Hyperlink,Nsstring,NSString“在此处获取xxx iPhone应用程序”。在这个字符串“Here”中,我想给特定的URL赋予hyperlink。它用于FB共享,我正在使用UIActivityViewController。我不想使用UILabel。我知道这可能很愚蠢,。。。帮帮我 提前感谢极客们……如果此应用程序适用于IOS6或更高版本,那么您可以像那样使用NSMutableAttributedString。并根据此处字符串设置自定义按钮的框架 NSString *infoString=@"Get the S

NSString
“在此处获取xxx iPhone应用程序”。在这个字符串“Here”中,我想给特定的
URL
赋予
hyperlink
。它用于FB共享,我正在使用
UIActivityViewController
。我不想使用
UILabel
。我知道这可能很愚蠢,。。。帮帮我


提前感谢极客们……

如果此应用程序适用于IOS6或更高版本,那么您可以像那样使用
NSMutableAttributedString
。并根据
此处
字符串设置自定义按钮的框架

 NSString *infoString=@"Get the Solestruck iPhone App Here";

        NSMutableAttributedString *attString=[[NSMutableAttributedString alloc] initWithString:infoString];
        NSInteger _stringLength=[infoString length];

        // ------------------ Give your range for underline
        [attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:1] range:NSMakeRange(_stringLength-4, 4)];

        lbl.attributedText = attString;

        [lbl setBackgroundColor:[UIColor clearColor]];

        // ---------------- Give frame according to your text -------
//-------------------- Small change in below two line ------------
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(lbl.frame.size.width-50, 0,50, lbl.frame.size.height);
        [btn setBackgroundColor:[UIColor redColor]];

        [btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside];

        [lbl addSubview:btn];

        [lbl setUserInteractionEnabled:YES];
见下图


如果你想在Facebook上分享,你需要告诉Safari打开一个URL,该URL将显示一个允许用户分享的Facebook页面。以下是一个例子:

//The url you want to share
NSString *urlString = @"http://stackoverflow.com";

//The title you want to be displayed on Facebook
NSString *title = "The Title of the Page";

//Create the URL string which will tell Facebook you want to share that specific page 
NSString *shareUrlString = [NSString stringWithFormat:@"http://www.facebook.com/sharer.php?u=%@&t=%@", urlString , title];

//Create the URL object 
NSURL *url = [ [ NSURL alloc ] initWithString:shareUrlString ];

//Launch Safari with the URL you created        
[[UIApplication sharedApplication] openURL:url];

//Release the object if you don't need it
[url release];

谢谢,我会试试这个,让你知道它的状态。但我为什么要去买这个按钮呢。无需再次共享另一个映像。还有其他类似于iOS的东西吗?你需要活动按钮,我不知道。目的是在FB中分享。我们已经在与消息共享一个图像。UIbutton解决不了这个问题。。。无论如何,谢谢我编辑的答案,你会得到你的答案根据我。谢谢Xman。但是,共享进展顺利,我只面临提供NSString链接的问题。@arpit否,更改了设计Lol。如果找到解决方案,请告诉我您找到解决方案了吗?德克萨斯州