1

我有一个客户列表的SplitViewController打开ModalView,选择客户端后,我打开包含在它上面的所有信息与下面的代码modalView:从ModalView

detailsForm *detView = [[[detailsForm alloc] setDict:[[self.curClientList objectAtIndex:indexPath.row] attributes]] autorelease]; 
[detView setModalPresentationStyle:UIModalPresentationPageSheet]; 
[detView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; 
[self presentModalViewController:detView animated:YES]; 

然后,在该控制器上有一个“编辑”按钮,应该打开另外1个模态视图。 按钮事件有以下代码:

NSLog(@"Edit button clicked"); 
editNewClient *editView = [[[editNewClient alloc] edit:YES setEditData:self.resultsDict] autorelease]; 
[editView setModalPresentationStyle:UIModalPresentationPageSheet]; 
[editView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; 
[self.splitViewController presentModalViewController:editView animated:YES]; 

没有任何反应。如果我更改线路

[self.splitViewController presentModalViewController:editView animated:YES]; 

[self presentModalViewController:editView animated:YES]; 

我得到一个异常:

-[detailsForm viewControllers]: unrecognized selector sent to instance 0x53882d0 

有什么不对? 或者我不得不使用代表?

回答

2

presentModalViewController仅在ViewController中使用时才有效。这是一个UIViewController消息。在这种情况下,我不认为你的'自我'是一个控制者。这就是选择器无法识别的原因。如果我是你,我会使用委托来做到这一点。我希望这有帮助。

+0

嗯,我修好了。上面的代码是“OK”。问题出现在第二个视图控制器中,该视图控制器有一个与父级父对象的链接断开,该对象似乎不是控制器,就像你说的。现在一切正常,谢谢。 – Razp 2011-04-01 11:00:31

+0

很高兴我能帮到你。 – Joze 2011-04-01 11:06:37