0

最近、テーブルセルからカスタムuiactionsheetを提示するクラスを作成しました。このアクションシートには、ピッカービューとツールバーがあります。ツールバーの[完了]ボタンを押すと、選択したピッカービュー値とともに通知が送信され、アクションシートが閉じられます。[完了]ボタンを押すと、アクションシートがビューから消えることがありますが、表示されるビューで何も選択できないため、そのアクションシートのモーダルプロパティが残っているように見えます。別のタブに移動して戻ってくると、これは解決するようです。誰かがこれを引き起こしている可能性のあるアイデアを持っていますか?

以下は、アクションシートを閉じるために使用するコードです。

-(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];


}

このかなり長い投稿を読むために時間を割いてくれてありがとう、ウィル

4

2 に答える 2

0

私はなんとかこれを解決することができましたが、それはハックのように感じます、私は以下を使用してコードに遅延を導入しました:

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

dismissFromActionSheetは次のとおりです。

-(void)dismissFromActionSheet{
 [self dismissWithClickedButtonIndex:0 animated:YES];
}
于 2010-12-10T17:39:11.523 に答える
0

私の知る限り、actionSheet:clickedButtonAtIndexメソッドを使用する必要があります。

-(IBAction)showActionSheet:(id)sender {
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive Button" otherButtonTitles:@"Other Button 1", @"Other Button 2", nil];
    sheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [sheet showInView:self.view];
    [sheet release];
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        self.label.text = @"Destructive Button Clicked";
    } else if (buttonIndex == 1) {
        self.label.text = @"Other Button 1 Clicked";
    } else if (buttonIndex == 2) {
        self.label.text = @"Other Button 2 Clicked";
    } else if (buttonIndex == 3) {
        self.label.text = @"Cancel Button Clicked";
    }
}
于 2010-12-10T10:51:29.227 に答える