【发布时间】:2014-01-13 10:46:34
【问题描述】:
我试图在 SkView 上显示 UIActivityViewController,但 xcode 给了我这个错误:
“GameOver”没有可见的@interface 声明选择器 'presentViewController:animated:completion:'
- (void)shareScore {
//add view
UIView *Sview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 512, 512)];
UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"shareScoreImg.png"]];
image.frame = Sview.frame;
[Sview addSubview:image];
//add label
CGRect fframe = self.view.frame;
UILabel *score = [[UILabel alloc] initWithFrame:fframe];
score.text = @"9999";
score.textAlignment = NSTextAlignmentCenter;
score.textColor = [UIColor darkGrayColor];
score.center = CGPointMake(250, 440);
score.font = [UIFont fontWithName:@"Pixel LCD7" size:50];
[Sview addSubview:score];
//capture view
UIGraphicsBeginImageContextWithOptions(Sview.bounds.size, Sview.opaque, 0.0);
[Sview.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:@[screenshot]
applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
}
如何在 SKScene 上呈现预设的 viewController? 谢谢。
【问题讨论】:
-
你不能,
UIView或任何其他视图没有presentViewController: animated:completion:的方法。该方法仅适用于UIViewController -
@rckoenes 那么我怎样才能将游戏的分数分享到 Facebook 等...?!!!!
-
通过 ViewController 或窗口。
-
@rckoenes 我的意思是在游戏中!!!这是SKScene
-
您不想在游戏过程中显示分享分数按钮,是吗?使用不同的 ViewController 为 Game Over 屏幕创建不同的视图
标签: ios iphone objective-c xcode sprite-kit