【发布时间】:2014-02-27 03:52:25
【问题描述】:
我有包含用户名作为占位符的动态文本,我想用实际用户名替换用户名的占位符,但我希望这个名称是可链接的,换句话说,当我点击用户名时它应该执行重定向到个人资料页面的某个选择器。这是可行的吗?
这是我的代码:
NSString *originalText = @"go to :user profile or go to :place";
NSString *userText = @"Sawsan";
NSString *placeText = @"SomePlace";
originalText = [originalText stringByReplacingOccurrencesOfString:@":user"
withString:userText];
originalText = [originalText stringByReplacingOccurrencesOfString:@":place"
withString:placeText];
self.mainLabel.text = originalText;
/*
* Result is: "go to Sawsan profile or go to SomePlace"
*/
我可以用 Sawsan 和 SomePlace 替换 :user 和 :place,当用户点击它们中的任何一个时,它们可以执行不同的 selector?
【问题讨论】:
标签: ios objective-c nsstring uitextview