Unrecognized selector sent to instance

后端 未结 3 1938
遥遥无期
遥遥无期 2020-12-21 09:36

Anyone know why I am getting this error?

Terminating app due to uncaught exception \'NSInvalidArgumentException\', reason: \'-[CustomRaisedTabViewController          


        
相关标签:
3条回答
  • 2020-12-21 10:14
    action: @selector(cancel:) 
    

    For the action selector which takes parameter! cancel: that means which will take another parameter.

    change your method to

    -(IBAction)cancel:(id)sender{
    // Do wat you want
    }
    
    or
    
    -(IBAction)cancel:(UIButton *)btnSender{
    /// Do what you want
    }
    
    0 讨论(0)
  • 2020-12-21 10:21

    you have to modify the cancel method signature in

    -(IBAction)cancel:(id)sender
     { 
       [self.parentViewController dismissModalViewControllerAnimated:YES]; 
     }
    

    when you added the action to your cancelButton (during initialization) you specified the "cancel:" selector, this means that it will be called a method having one parameter (the sender button)

    0 讨论(0)
  • 2020-12-21 10:24

    Because the cancel: method is not cancel which is what you've defined.

    Change your cancel action to look like this:

    - (IBAction)cancel:(id)sender {
        ...
    }
    
    0 讨论(0)
提交回复
热议问题