问题:
向html" class="superseo">UIAlertController 添加超链接怎么办?
解决:
[mUIAlertController setValue:viewController forKey:@"contentViewController"];
最终通过替换contentViewController,暂时解决。
UIAlertController* mUIAlertController = [UIAlertController alertControllerWithTitle:@"用户须知"
message:@"" preferredStyle:UIAlertControllerStyleAlert];
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
paraStyle.alignment = NSTextAlignmentLeft;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:message attributes:@{NSParagraphStyleAttributeName:paraStyle,NSFontAttributeName:[UIFont systemFontOfSize:14.0]}];
[attributedString addAttribute:NSLinkAttributeName value:@"agreement://" range:[[attributedString string] rangeOfString:@"《用户协议》"]];
[attributedString addAttribute:NSLinkAttributeName value:@"policy://" range:[[attributedString string] rangeOfString:@"《隐私政策》"]];
UIViewController *viewController = [[UIViewController alloc]init];
PHTTextView *textView = [[PHTTextView alloc]initWithFrame:CGRectMake(10, 0, 250,100)];
textView.attributedText =attributedString;
textView.editable = NO;
textView.scrollEnabled = YES;
textView.backgroundColor = [UIColor clearColor];
textView.delegate =self;
[viewController.view addSubview:textView];
[mUIAlertController setValue:viewController forKey:@"contentViewController"];
UITextView实现UITextViewDelegate接口,在(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction,方法中做相关点击处理
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction{
if ([[URL scheme] isEqualToString:@"agreement"]) {
PrivacyAgreementViewController* orderVc = [PrivacyAgreementViewController new];
orderVc.name = @"xxx_user_agreement";
[self.navigationController pushViewController:orderVc animated:YES];
// [self dismissViewControllerAnimated:YES completion:nil];
return NO;
}else if ([[URL scheme] isEqualToString:@"policy"]) {
PrivacyAgreementViewController* orderVc = [PrivacyAgreementViewController new];
orderVc.name = @"xxx_policy";
[self.navigationController pushViewController:orderVc animated:YES];
// [self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
return YES;
}
余下问题:对话框高度宽度怎么设置?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)