在应用程序的two actionsheet buttons
上具有one modalviewcontroller
和mainviewcontroller
。现在对于两个actionsheet
按钮和modalviewcontroller
,我可以为每个按钮设置多个dismissviewdidfinish method
-(void)dismissViewDidFinish:(ModalViewController *)controller
{
[self dismissModalViewControllerAnimated:YES];
}
-(void)dismissViewDidFinish:(Devanagari *)controller1;
{
[self dismissViewControllerAnimated:completion];
}
-(void)dismissViewDidFinish:(English *)controller2;
{
[self dismissViewControllerAnimated:YES];
}
原因是,如果我在mainviewcontroller上添加这三种方法,则会收到红色警告消息
duplicate declaration of method dismissviewdidfinish
。任何想法如何解决这种情况。
最佳答案
您不能为多个方法使用相同的名称。使用单个dismissViewDidFinish:(UIViewController *)viewController
方法,然后检查哪个viewController完成:
- (void)dismissViewDidFinish:(UIViewController *)viewController {
//check to see what kind of class viewController is
//or use tags by setting the viewcontroller.view.tag when creating it
}
关于iphone - 方法的重复声明dismissviewdidfinish,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9895498/