0

ビューコントローラーに1つのテーブルビューがあり、その中にcustomTableViewCellがあります。カスタムビューセルにランタイムを生成する動的ボタンがあります。そのボタンをクリックすると、カスタムテーブルビューセルを持つテーブルビューコントローラーを保持しているビューコントローラーを別のビューにプッシュしたいコントローラーなのでどうすればいいですか?私のcustometableviewcell.mファイルには、このボタンがあります。

CommentButton = [[UIButton alloc]init];
        CommentButton.frame = CGRectMake(CommentLabel.frame.origin.x+CommentLabel.frame.size.width+5, 5, 110, 35);
        CommentButton.titleLabel.font = [UIFont systemFontOfSize:12];
        [CommentButton setTitle:@"Add Comment" forState:UIControlStateNormal];
        CommentButton.backgroundColor = [UIColor clearColor];
        [CommentButton addTarget:self action:@selector(GoToComment:) forControlEvents:UIControlEventTouchUpInside];

customtableviewcell.m以下は、コメントボタンのクリックで呼び出されるファイル内の私の事後通知です

-(IBAction)GoToComment:(id)sender {

[[NSNotificationCenter defaultCenter] postNotificationName:@"GoToComment" object:nil];

}

上記は、私が登録したこのボタンでNSNotification、次のメソッドと呼ばれます

[[NSNotificationCenter defaultCenter] addObserver:self
                                            selector:@selector(GotoComents)
                                                name:@"GoToComment" object:nil];

上記の行は、そのcustomtableviewcellでテーブルビューを持っているviewcontrollのviewdidloadにあります。

そしてcustomtableviewセルから、新しいView Controllerをプッシュする上記の通知を投稿しています

-(void)GotoComents
{  
    TableTextViewController *settingView=[[TableTextViewController alloc]initWithNibName:@"TableTextViewController" bundle:nil];
    [self.navigationController pushViewController:settingView animated:YES];




}

今、私はcustomTableViewcellから呼び出してviewcontrollerメソッドを呼び出すnsnotoficationセンターでそれをやったところです。

しかし、それは正しい方法ですか?そうでない場合は、どうすればこれを達成できるか教えてください。ランタイムを生成する動的ボタンがあることを覚えています。

4

6 に答える 6

2

オンクリックボタンイベント

-(void)buttonAction:(UIButton*)sender
    {

    YourViewControllerVC *yvc=[YourViewControllerVC alloc] init];
    [self.yournavigatioonController pushViewController:yvc animated:YES];

    }
于 2013-08-06T06:07:22.150 に答える
1

TableViewController サブクラスをカスタム セル デリゲートとして宣言し、その中に GoToComment メソッドを作成してから、代わりに

[CommentButton addTarget:self action:@selector(GoToComment:) forControlEvents:UIControlEventTouchUpInside];

行う

[CommentButton addTarget:self.delegate action:@selector(GoToComment:) forControlEvents:UIControlEventTouchUpInside];
于 2013-08-06T06:06:01.367 に答える
0

あなたはあなたの質問を正しく説明していません..あなたはこのようにやりたいことができます:

    LoginViewController * login_view = [[ LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    UINavigationController *Nav01 = [[UINavigationController alloc] initWithRootViewController:login_view];

    Nav01.navigationBar.hidden = YES;
    login_view.fromProfileView = FALSE;
    [self presentModalViewController:Nav01 animated:YES];
于 2013-08-06T06:52:02.107 に答える