操作表被标签栏捕获

发布于 2024-10-06 20:47:21 字数 2001 浏览 0 评论 0原文

这是一个棘手的问题,我已经研究了一段时间了。我有一个操作表出现在带有选项卡栏的视图中,有时当我关闭操作表时,它会被“捕获”在选项卡栏中并且无法执行任何操作。该应用程序不会崩溃,因为如果我最小化它然后回来它被驳回,只是似乎模态行为没有被正确驳回。

我最近将操作表的显示方式从“showInView”更改为“showFromTabBar”,并且不确定这是否会造成问题。

谢谢, William

编辑:

下面是我用来关闭操作表的代码:

-(void)doneButtonPressed:(id)sender{



    if ([[self viewWithTag:1] isKindOfClass:[PickerView class]]) {

        PickerView *picker = (PickerView *)[self viewWithTag:1];

        if (picker.selectedRow == nil) {
            [picker populateSelectRowForRow:0 andComponent:0];
        }

        NSNotification *note = [NSNotification notificationWithName:@"doneButtonPressed" object:self.indexPath userInfo:picker.selectedRow];

        [[NSNotificationCenter defaultCenter] postNotification:note];

    }else {

        DatePickerView *picker = (DatePickerView *)[self viewWithTag:1];

        NSDictionary *extraInfo = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] initWithObjects:[self formatDateToString:[picker date]], nil] forKeys:[[NSArray alloc] initWithObjects:@"value", nil]];

        NSNotification *note = [NSNotification notificationWithName:@"doneButtonPressed" object:self.indexPath userInfo:extraInfo];

        [[NSNotificationCenter defaultCenter] postNotification:note];
    }


    [self dismissWithClickedButtonIndex:0 animated:YES];
}

以及调用的通知方法:

-(void)pickerUpdate:(NSNotification *)note{

    NSIndexPath *indexPath = [note object];
    NSDictionary *extraInfo = [note userInfo];

    NSDictionary *dict = [[tableController.sectionAndFields objectAtIndex:indexPath.section] objectAtIndex:(indexPath.row + kHeaderAndFooterOffset)];

    [tableController.formDetails setObject:[extraInfo objectForKey:@"value"] forKey:[dict objectForKey:@"key"]];

    NSArray *reloadArray = [[NSArray alloc] initWithObjects:indexPath, nil];
    [indexPath release];

    [self.tv reloadRowsAtIndexPaths:reloadArray withRowAnimation:NO];
    [reloadArray release];


}

This is a tricky one that I've been working on for a while. I have a an action sheet that appears in a view with a tabbar, sometimes when I dismiss the action sheet it gets "caught" in the tabbar and am unable to do anything.The app doesn't crash because if i minimize it and then come back in it is dimissed, it just appears that the modal behavior isn't being dismissed properly.

I recently changed how the action sheet is displayed from "showInView" to "showFromTabBar" and am not sure if this is creating the issue.

Thanks,
William

Edit:

Below is the code I use to dismiss my actionsheet:

-(void)doneButtonPressed:(id)sender{



    if ([[self viewWithTag:1] isKindOfClass:[PickerView class]]) {

        PickerView *picker = (PickerView *)[self viewWithTag:1];

        if (picker.selectedRow == nil) {
            [picker populateSelectRowForRow:0 andComponent:0];
        }

        NSNotification *note = [NSNotification notificationWithName:@"doneButtonPressed" object:self.indexPath userInfo:picker.selectedRow];

        [[NSNotificationCenter defaultCenter] postNotification:note];

    }else {

        DatePickerView *picker = (DatePickerView *)[self viewWithTag:1];

        NSDictionary *extraInfo = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] initWithObjects:[self formatDateToString:[picker date]], nil] forKeys:[[NSArray alloc] initWithObjects:@"value", nil]];

        NSNotification *note = [NSNotification notificationWithName:@"doneButtonPressed" object:self.indexPath userInfo:extraInfo];

        [[NSNotificationCenter defaultCenter] postNotification:note];
    }


    [self dismissWithClickedButtonIndex:0 animated:YES];
}

and the notification method that is called:

-(void)pickerUpdate:(NSNotification *)note{

    NSIndexPath *indexPath = [note object];
    NSDictionary *extraInfo = [note userInfo];

    NSDictionary *dict = [[tableController.sectionAndFields objectAtIndex:indexPath.section] objectAtIndex:(indexPath.row + kHeaderAndFooterOffset)];

    [tableController.formDetails setObject:[extraInfo objectForKey:@"value"] forKey:[dict objectForKey:@"key"]];

    NSArray *reloadArray = [[NSArray alloc] initWithObjects:indexPath, nil];
    [indexPath release];

    [self.tv reloadRowsAtIndexPaths:reloadArray withRowAnimation:NO];
    [reloadArray release];


}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

司马昭之心 2024-10-13 20:47:21

我确实设法解决了这个问题,但感觉很像黑客,我使用

[self performSelector:@selector(dismissFromActionSheet) withObject:nil afterDelay:0.2];

以下方法在代码中引入了延迟:

-(void)dismissFromActionSheet{
 [self dismissWithClickedButtonIndex:0 animated:YES];
}

I did manage to solve this however it feels very much like a hack, I introduced a delay into the code using:

[self performSelector:@selector(dismissFromActionSheet) withObject:nil afterDelay:0.2];

With dismissFromActionSheet being:

-(void)dismissFromActionSheet{
 [self dismissWithClickedButtonIndex:0 animated:YES];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文