gpt4 book ai didi

iphone - UIActionSheet出现两次

转载 作者:行者123 更新时间:2023-12-01 18:23:20 24 4
gpt4 key购买 nike

我正在函数quizEnded内创建UIActionSheet。
按钮之一将用户带入Game Center。当他们从游戏中心返回时,quidended在viewdidappear内部再次被调用。这是在较早版本的上方创建第二个操作表格。

https://www.youtube.com/watch?v=QrY1Awt3RX0

我不认为再次调用quizEnded会导致问题,而不是我没有正确消除第一个UIActionSheet。

-(void)viewDidAppear {
// some code ...
if(self.quizDidEnd > 0){
[BT_debugger showIt:self theMessage:@"@@@Calling quiz ended###"];

[self quizEnded];
}
}// end viewDidAppear
// initialize button array
-(void)quizEnded {
// some code ...
_finishedButtons = [[NSMutableArray alloc] init];

// show either the reward screen or the finished screen or quit to menu

if(earnedReward == TRUE && haveRewardScreen==TRUE) {
[_finishedButtons addObject:NSLocalizedString(@"quizShowReward", @"Show Reward")];
//[self showQuizRewardScreen];

}else {
if(haveFinishScreen==TRUE){

[_finishedButtons addObject:NSLocalizedString(@"continue", @"Continue")];
//[self showFinishScreen];

}else {
// if no finish screen then send back to rootviewcontroller
[_finishedButtons addObject:NSLocalizedString(@"quit", @"Quit")]; }
}

if(_enableGameCenter) {
[_finishedButtons addObject:NSLocalizedString(@"Game Center", @"Game Center")];
}

// initialize UIAction sheet
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:quizResultMessage
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles: nil];


//add the buttons to the action sheet
for (int i = 0; i < [_finishedButtons count]; i++) {
[actionSheet addButtonWithTitle:[_finishedButtons objectAtIndex:i]];
}

actionSheet.destructiveButtonIndex = [_finishedButtons count];

[actionSheet setActionSheetStyle:UIActionSheetStyleBlackOpaque];



//is this a tabbed app?
if([appDelegate.rootApp.tabs count] > 0){
[actionSheet showFromTabBar:[appDelegate.rootApp.rootTabBarController tabBar]];
}else{
[actionSheet showInView:self.view];
}

[actionSheet release];

}//self.quizDidEnd == 0


}// end quizEnded
-(void)actionSheet:(UIActionSheet *)actionSheet  clickedButtonAtIndex:(NSInteger)buttonIndex {


[BT_debugger showIt:self theMessage:@"!!!action sheet called!!!"];

NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];

//quit only used if no finished or reward screen present
if([buttonTitle isEqual:NSLocalizedString(@"quit", @"Quit")]){

// if no finish screen then send back to rootviewcontroller
[self.navigationController popToRootViewControllerAnimated:YES];
[BT_debugger showIt:self theMessage:@"Quit tapped"];
}


//show reward
if([buttonTitle isEqual:NSLocalizedString(@"quizShowReward", @"Show Reward")]){
[self showQuizRewardScreen];
[BT_debugger showIt:self theMessage:@"Show Reward Tapped"];
}

//show continue
if([buttonTitle isEqual:NSLocalizedString(@"continue", @"Continue")]){
[self showFinishScreen];
[BT_debugger showIt:self theMessage:@"Continue Tapped"];
}

//show game center
if([buttonTitle isEqual:NSLocalizedString(@"Game Center", @"Game Center")]){
[BT_debugger showIt:self theMessage:@"game center tapped"];
[self showGameCenter];
_altend = 0;

}

}// end

最佳答案

如果此手势显示菜单,请确保将所有代码放入其中:

    if(gestureRecognizer.state == UIGestureRecognizerStateBegan) { }

否则,可能会有第二个部分的手势发生了更改(UIGestureRecognizerStateChanged),这导致操作表两次触发。

关于iphone - UIActionSheet出现两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15693466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com