私は、プレーヤーがスコアをつけることができるiPhoneゲームを持っています。 私はこれにTWTweetComposeViewControllerを使用します。遅延のあるレイヤー
Twitterシートが読み込まれるまでに時間がかかることがあるので、Twitterシートが表示されるのを待っている間に、プレーヤーがTwitterボタンをクリックした後に表示される「読み込み中...」レイヤーが必要です。
私の問題は、ツイートシートの準備が整ったら、レイヤー(以下のコードでは "colcol"という名前)が表示されることです。これは、ツイートシートが表示されるのを待っているかのようです。それは間違いなく私が期待しているものではありません。
任意のアイデアなぜですか?
ありがとうございました!一般に
- (void) tweetScore: (CCMenuItem *) menuItem {
colcol=[CCLayerColor layerWithColor:ccc4(0,0, 0, 200) width:50 height:50];
colcol.position=ccp(winSize.width/2-25,winSize.height/2-25);
[self addChild:colcol z:15];
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:[NSString stringWithFormat:@"I scored %d!", playerScore]];
tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result) {
[appDelegate.viewController dismissModalViewControllerAnimated:YES];
switch (result) {
case TWTweetComposeViewControllerResultCancelled:
[self removeChild:colcol cleanup:YES];
break;
case TWTweetComposeViewControllerResultDone:
[[GCHelper sharedInstance] reportAchievementIdentifier:@"tweet_score" percentComplete:100.0];
[self removeChild:colcol cleanup:YES];
break;
default:
[self removeChild:colcol cleanup:YES];
break;
}
};
[appDelegate.viewController presentModalViewController:tweetSheet animated:YES];
}
else
{
// handle this case
}
}
私はこの権利を行使していないと思います。私は[self addChild:colcol z:15]の後にすべてのコードを入れました。このdispatch_async(dispatch_get_main_queue()、....)に表示される前にレイヤーが終了するまで待っています。 – David
インジケータが起動した後に、何かを簡単にする方法が悲しいほど曖昧になっています。そこに解決策がありますが、最も一般的な解決策は[self performSelector:@selector(doWork)withObject:nil afterDelay:0.0]; – karmington
のようです。 – David