Calling a function from a different view controller for iphone

后端 未结 3 1864
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-13 04:53

I have a problem where I want to call a function defined in one view controller from another controller. I\'v try what seems llke a hundred different setups and nothing seem

3条回答
  •  忘掉有多难
    2021-01-13 05:25

    Why not just have a button send both messages directly to their respective controllers? Instances of UIButton are inherently capable of sending multiple messages to multiple targets. To configure the button, you can send the following message as many times as necessary:

    - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
    

    You can also wire the button up in Interface Builder to do the same thing. Or mix and match to your hearts content.

提交回复
热议问题