【发布时间】:2016-04-19 08:21:17
【问题描述】:
技术:Objective-C、xCode 7
@property (nonatomic, copy) NSString *notes;
@synthesize notes;
example.notes = @"Click <a href='http://www.google.com'>here</a>";
NSString *msg = [@"" stringByAppendingFormat:@"%@", myAnnotation.notes];
UIAlertController *alertViewController = [UIAlertController alertControllerWithTitle: @"Title of Alert Box" message: msg preferredStyle: UIAlertControllerStyleAlert];
[alertViewController addAction: [UIAlertAction actionWithTitle: @"Close" style: UIAlertActionStyleCancel handler: nil]];
[self presentViewController: alertViewController animated: YES completion: nil];
试图让链接出现在警报框中,但没有成功。只是输出为纯文本。
这甚至可能吗?如果是这样,使用我上面的示例,您将如何实现它?
【问题讨论】:
-
不,不可能。
UIAlertController只支持纯文本。 -
NSString *msg = [@"" stringByAppendingFormat:@"%@", myAnnotation.notes];的意义何在?为什么不NSString *msg = myAnnotation.notes;? -
这只是一个例子。我正在向警报框中添加更多符号,所以我需要附加它。
-
您不能添加超链接,但是,您可以将链接显示为纯文本并添加 UIAlertAction,单击它会重定向到链接。
-
@MeharoofNajeeb 嗯,好吧,是的,这听起来像是一条路。您是否碰巧知道添加自定义 AlertAction 的好示例
标签: ios objective-c uialertcontroller