我想提出上SkView
UIActivityViewController
但Xcode中給了我這個錯誤:上SKScene
爲「GAMEOVER」不可見@interface聲明選擇 「presentViewController:動畫:完成:」
- (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];
}
我可以如何呈現一個預設的viewController上SKScene? 謝謝。
你不能,'UIView'或任何其他視圖沒有'presentViewController:animated:completion:'方法。該方法只適用於'UIViewController' – rckoenes
@rckoenes那麼我怎樣才能將遊戲的分數分享給Facebook等等? –
通過ViewController或窗口。 – rckoenes