在应用程序的two actionsheet buttons上具有one modalviewcontrollermainviewcontroller。现在对于两个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/

10-10 20:31