2

在我的应用程序中,我使用 aUITableView来显示特定日期的医生预约情况。在两个手势识别器的帮助下,我可以在表格视图上滑动以显示下一天(从右向左滑动)/前一天(从左向右滑动)。

当我滑动时,我检查我是否已经从数据库中加载了预订,如果没有加载,我会显示一个带有活动指示器的警报视图,以向用户显示它正在加载。

加载完成后,我关闭此警报视图并显示翻转视图 ( UIViewAnimationTransitionFlipFromLeft) 并显示新的一天的动画。

现在的问题是:翻转视图后,didSelectRowAtIndexPath:当我第一次点击一个单元格时没有被调用。但如果我再次点击它,该方法就会触发。看来我首先必须点击视图中的任意位置才能“激活视图”。alertview 是否可能仍然以某种方式出现在 tableview 的顶部?

处理从左到右滑动的代码:

-(void)handleSwipeR
{
//Disable user interaction.
[table setUserInteractionEnabled:NO];
[self.navigationController.navigationBar setUserInteractionEnabled:NO];

if (swipeEnabled == YES) {
    swipeEnabled = NO;

    //we use the curIndex to check if it is necessary to get new data.
    if (curIndex > 0)
    {
        //Commit the animations and reload all the data.
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:table cache:NO];
        [UIView setAnimationDuration:1];
        [UIView setAnimationDidStopSelector: @selector(animationFinished:finished:context:)];
        [UIView commitAnimations];
        curIndex --;
        [Database setCurDate:[keys objectAtIndex:curIndex]];
        [table reloadData];
    }else {
        //We show a loading screen until the new reservation data is collected.
        loading=[[UIAlertView alloc] initWithTitle:loadingText message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
        loadingInd=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        [loadingInd startAnimating];
        [loadingInd setFrame:CGRectMake(125, 60, 37, 37)];
        [loading addSubview:loadingInd];
        [loading show];

        [Database setCurAlert:loading];

        [Database setCurDate:[keys objectAtIndex:curIndex]];

        //Set startdate and enddate and get the new reservations.
        NSDate *startDate = [[Database curDate] dateByAddingTimeInterval:-60*60*24*15];
        NSDate *endDate = [[Database curDate] dateByAddingTimeInterval:-60*60*24*1];
        [Database getReservations:startDate endDate:endDate];
        [self fillVariables];
        [loading dismissWithClickedButtonIndex:0 animated:YES];
        //You get a unique id each session. If you logged in at another location, the session id will change. So the first one is invalid. So we first check if the session id is still valid.
        if (![Database sessionExpired]) {
            //If there aren't found any reservations for the next two weeks. Show an Alertview.
            if ([Database elementFound] == NO) {
                reservationSearch = 2;

                alertNoResMessage = [NSString stringWithFormat:[LanguageStrings resListNoResMessageSwipeR],reservationSearch];

                //sleep(1);
                alertNoRes= [[UIAlertView alloc]initWithTitle:alertNoResTitle message:alertNoResMessage delegate:self cancelButtonTitle:alertNoResButtonYes otherButtonTitles:alertNoResButtonNo, nil];

                alertNoRes.tag = 201;
                [alertNoRes show];
            }else {
                //Commit the animations and reload all the data.
                curIndex = [keys indexOfObject:[Database curDate]];
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationDelegate:self];
                [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:table cache:NO];
                [UIView setAnimationDuration:1];
                [UIView setAnimationDidStopSelector: @selector(animationFinished:finished:context:)];
                [UIView commitAnimations];
                curIndex --;
                [Database setCurDate:[keys objectAtIndex:curIndex]];
                [table reloadData];
            }
        }
    }
    swipeEnabled = YES;
}
}

//Enable all user interaction when the animation is finished.
- (void) animationFinished:(NSString *)animationID finished:(BOOL)finished context:  (void *)context{
[table setUserInteractionEnabled:YES];
[self.navigationController.navigationBar setUserInteractionEnabled:YES];
swipeEnabled = YES;
}

我一直在寻找它一段时间,我似乎没有找到答案,所以你的帮助将不胜感激。

4

0 回答 0