简体   繁体   中英

Handle click from custom view controller using swift in ios

storyboard snapshot crash report I am new in iOS development, I have a View Controller in main storyboard except main view Controller. In custom view controller I have put a button and when I click the button from custom view controller layout, app crashes. How to handle click events or any kind of web view or events? Is there anything in iOS like manifest in android for declaring new view controller?

I want to link with 'Build your sandae' button which is written in CustomWig view controller Kindly reply to the post.

You can solve this issue with taken action handler from your current custom screen to another main screen.

In main screen you need to implement that handler and in custom view you need to declare and call that button action handler method.

in your CustomScreen add callBack like this

var actionHandler: (() -> Void)?

than call this callback when click on button

self.actionHandler?()

now go to their main screen where your customScreen and initialize it and put this code for handling button action

 vc.actionHandler = { 
    //do your code here
 }

Here "vc" is your custom screen instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM