testViewController是继承UIViewController,而下面的代码是继承在UIVIEW类里,而不是继承UIVIEWCONTRLLER.但是下面的代码一但执行到 [self presentModalViewController:_setViewController animated:YES];就会出错。请问怎么样才可以切换到另外一个UIVIEWController里。急着请教!!!!!!!    testViewController *_setViewController = [[testViewController alloc]init];
    [self presentModalViewController:_setViewController animated:YES];
    [_setViewController release];
    [self dismissModalViewControllerAnimated:YES];

解决方案 »

  1.   

    既然的的代码是在继承uiview的类中,当然就没有presentModalViewController方法啦所以需要在你的view中加入一个delegate,将delegate指向你的viewcontroller(必须继承uiviewcontroller),然后[delegate presentModalViewController:_setViewController animated:YES];这样才可以
      

  2.   

    切换到另外一个UIVIEWController里 ?
    你是想取到Controller的话 传值就可以了,简单的就是写个方法把指针附过去
      

  3.   

    presentModalViewController 属于UINavigationController的实例方法。你需要修改一下你的代码
    这一句:
     [self presentModalViewController:_setViewController animated:YES];
    改成
     [self.navigationController presentModalViewController:_setViewController animated:YES];再把后面的
    [self dismissModalViewControllerAnimated:YES];
    删除,再试