1

UIActionSheetactionSheet と呼ばれるのインスタンスであるクラス変数があります。UIPickerViewのインスタンスとのインスタンスを追加しますUISegmentedControl。「完了」ボタン (UISegmentedControl のインスタンス) をタップすると、クラス メソッドの disconnectActionSheet は呼び出されません。誰でも私を助けることができますか?

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

-(IBAction)chooseTopicButtonPressed{


    actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                             delegate:nil
                                                    cancelButtonTitle:nil
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:nil];

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

    UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
    pickerView.showsSelectionIndicator = YES;
    pickerView.dataSource = singlePicker.dataSource;
    pickerView.delegate = singlePicker.delegate;

    [actionSheet addSubview:pickerView];


    UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
    closeButton.momentary = YES;
    closeButton.frame = CGRectMake(10, 6, 300, 30);
    closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
    closeButton.tintColor = [UIColor blueColor];
    [closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventTouchUpInside];


    //dismissActionSheet NOT BEING CALLED FOR SOME REASON!!! 

    [actionSheet addSubview:closeButton];

    [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

    [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}


-(void)dismissActionSheet{
    NSLog(@"dismissActionSheet called");
    [actionSheet dismissWithClickedButtonIndex:0 animated:YES];

}
4

1 に答える 1

2

メソッドdismissActionSheetには引数がないため、@selector次のようにする必要があります。

[closeButton addTarget:self action:@selector(dismissActionSheet) forControlEvents:UIControlEventTouchUpInside];
于 2012-11-06T22:19:35.910 に答える