我正在使用UIActivityViewController进行分享按钮.当我从列表中选择邮件选项时它显示文本和网址但是当我选择Facebook或Twitter时它只显示文本而不是网址.我搜索了很多但没有得到我的问题的解决方案.我得到了在url中添加"http"的另一个解决方案,但这可能不在url中添加http.我的代码是 -
NSArray *activityItems;
NSString *str;
NSString *noteStr;
str = [NSString stringWithFormat:@"com.boxscoregames.squares://square?%@",squareID];
noteStr = @"You have been invited to join the Square game, please follow the link below on your iPhone.";
NSURL *url = [NSURL URLWithString:str];
// str =[NSString stringWithFormat:@"<html><a href=\"%@\">%@</a></html>" ,str,str];
activityItems = @[noteStr,url];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud) 我想在textfield中输入字母数字值.如果用户只输入字符或数字,则发送按钮.即使没有特殊字符可以接受.
NSString *str = askIdTxt.text;
NSCharacterSet *alphanumericSet = [NSCharacterSet alphanumericCharacterSet];
NSCharacterSet *numberSet = [NSCharacterSet decimalDigitCharacterSet];
BOOL isAlphaNumericOnly = [[str stringByTrimmingCharactersInSet:alphanumericSet] isEqualToString:@""] && ! [[str stringByTrimmingCharactersInSet:numberSet] isEqualToString:@""];
if (isAlphaNumericOnly) {
NSLog(@"isAplhaNumericOnly: %@",(isAlphaNumericOnly? @"Yes":@"No"));
}
Run Code Online (Sandbox Code Playgroud)
这总是回归真实.我没有弄到这个错误.