0

サブビューとして aUIViewControllerのサブクラスを追加する a があります。UITableView

例えば

 @interface ViewController : UIViewController

    @interface ItemList : UITableView

( ) オブジェクトViewController viewDidLoadを作成し、それをビューに追加します。ItemListitemListviewcontroller

- (void)viewDidLoad {
 ...
  [self.view addSubview:itemList];
}

私はナビゲーションコントローラにアクセスできないので、別のものを にプッシュするにはどうすればdidSelectRowAtIndexPathよいですか?ItemListUITableViewviewcontrollernavigationcontroller

@implementation ItemList
{
 ...
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

        [self.navigationController pushViewController:newViewControllerobject animated:YES];

    }

}
4

2 に答える 2

1

AppDelegateで最初のnavigationControllerを定義している場合は、次のコードを使用して最上部のnavigationControllerを見つけ、その上にviewControllerをプッシュできます。

AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
[appDelegate.navigationController.visibleViewController.navigationController pushViewController:newViewControllerobject animated:YES];
于 2012-11-08T11:32:42.790 に答える
1

ViewController *mydelegateたとえば、itemList クラスでプロパティを作成します。ViewControllerのitemListを追加するときはviewDidLoad、次を追加します

 itemList.myDelegate = self;

先に進みます..オンは選択しました

 @implementation ItemList
@synthesize mydelegate;
    {
     ...
        - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

            [myDelegate.navigationController pushViewController:newViewControllerobject animated:YES];

        }

}
于 2012-11-08T10:57:52.433 に答える