0

UIToolBar オーバーレイに完了ボタンを重ねました。完了ボタンがツールバーに表示されますが、クリックできません。実際に触っても変化なし。明らかに、doneButton はアクションを受け取っていません。私の質問は、なぜ、どのようにこれを修正するのですか? 欠陥のあるコードを何に置き換える必要がありますか?

これがオーバーレイを設定した場所です。

- (UIView*)CommomOverlay  {
    //Main overlay(not pertinent in this question)
    UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,420)];
    UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,420)];
    [FrameImg setImage:[UIImage imageNamed:@"newGraphicOverlay.png"]];

    //Toolbar overlay
    UIToolbar *myToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 428, 320, 50)];
    [myToolBar setBarStyle:UIBarStyleBlack];

    //Done button overlay
    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] 
                                   initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                                        target:self
                                                        action:@selector(doneButtonPressed)];

    [myToolBar setItems:[NSArray arrayWithObjects: doneButton, nil] animated:YES];

    [FrameImg addSubview:myToolBar];
    [view addSubview:FrameImg];
    return view;
}

これが、私が使用した doneButton の押された方法論です。クリックすると、ビューは.h/.mがSecondViewControllerの名前にある別の画面に戻るはずです。

-(void)doneButtonPressed {

    SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil
    bundle:nil];
    screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:screen animated:YES];
    [screen release];
}

私にはすべてが完璧に見えますが、そうではないことは言うまでもありません。これはよくある質問のようですが、オーバーレイでボタンが機能しないことについては検索していません。修正部分だけでなく、なぜなのかについても議論してください。

4

1 に答える 1

0

次のようにして、これが機能するかどうかを確認できますか..

FrameImg.userInteractionEnabled = YES;

これが役立つかどうかはわかりません。

于 2012-07-25T05:18:46.587 に答える