我的 UIAlertView 目前有此代码:
if (counter > highscore) { //if highscore is achieved show an alert
highscore = counter;
NSString *nssHighscore = [NSString stringWithFormat:@"%i", highscore];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Congratulations, You Got A New High Score!!"
message:nssHighscore
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:@"Share"];
[alert show];
}
我想在警报上单击“共享”按钮时运行此代码
- (IBAction)PostToFacebook:(id)sender {
NSString *nssHighscore = [NSString stringWithFormat:@"%i", highscore];
mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:[NSString stringWithFormat:@"My New Highscore is %d - Try to Beat it!, highscore]];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
到目前为止,我一直在关注有关堆栈溢出的指南和问题,但无法使其正常工作。
谢谢