我想在UIActivityViewController
中添加一个整数,但它不起作用。这是我的代码:
- (IBAction)socialButton:(id)sender {
NSString *shareText = @"I just scored %i in Helicave!", scoreNumber;
NSArray *itemsToShare = @[shareText];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes = @[UIActivityTypePostToFlickr, UIActivityTypePostToTencentWeibo, UIActivityTypePostToWeibo, UIActivityTypePostToVimeo];
[self presentViewController:activityVC animated:YES completion:nil];
}
答案 0 :(得分:2)
这一行:
NSString *shareText = @"I just scored %i in Helicave!", scoreNumber;
需要:
NSString *shareText = [NSString stringWithFormat:@"I just scored %i in Helicave!", scoreNumber];
答案 1 :(得分:0)
尝试更改第一行
NSString *shareText = @"I just scored %i in Helicave!", scoreNumber;
为:
NSString *shareText = [NSString stringWithFormat:@"I just scored %i in Helicave!", scoreNumber];
在创建字符串
之前,您需要告诉XCode该字符串将具有格式,如%@
或%i