Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

SwifUI call the function in the cordinator

import Foundation
import SwiftUI
import UIKit

struct AnotherControllerView : UIViewControllerRepresentable {

    typealias UIViewControllerType = AnotherController

    func makeCoordinator() -> AnotherControllerView.Coordinator {
        Coordinator(self)
    }

    func makeUIViewController(context: UIViewControllerRepresentableContext<AnotherControllerView>) -> AnotherController {

        return AnotherController()
    }

    func updateUIViewController(_ uiViewController: AnotherController, context: UIViewControllerRepresentableContext<AnotherControllerView>) {

    }


    class Coordinator : NSObject {
        var parent : AnotherControllerView
        init(_ viewController : AnotherControllerView){
            self.parent = viewController
        }
    }
}

class AnotherController : UIViewController {


    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.blue
    }

    func savePhoto(){

        let alert = UIAlertController(title: "Save Photo to Camera Roll", message: "Would you like to save your drawing to the camera roll?", preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil))
        alert.addAction(UIAlertAction(title: "Save", style: .default, handler: someHandler))
        self.present(alert, animated: true)
    }

    func someHandler(alert: UIAlertAction!) {
        print("Handler executed")
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: uilabel without constraint 
Swift :: swift how to dereference unsafemutablepointer 
Swift :: xcode macosx have view resize when window size changed 
Swift :: swift print statement 
Swift :: how to use IBOutlet variables as static in swift 
Swift :: selenium lfor loops 
Swift :: Swift for Loop With Range 
Swift :: bzxjhjgvjgvjgvjv 
Swift :: Named Associated Values Swift 
Swift :: declare multiple variables at once in swift 
Swift :: swift get all cases starting with 
Swift :: Swift Function with Return Multiple Values 
Swift :: Compare AnyObjects en Swift 
Swift :: sizetofit not working swift 
Ruby :: rails include route helpers in console 
Ruby :: ruby variable in string 
Ruby :: rspec expect to receive multiple times 
Ruby :: travis ci NameError: uninitialized constant SimpleCov 
Ruby :: ruby min 2 numbers 
Ruby :: ruby multiline comment 
Ruby :: rails g model 
Ruby :: rails crud 
Ruby :: concatenate arrays in ruby 
Ruby :: ruby array unshift 
Ruby :: ruby hash.each 
Ruby :: log rails 
Ruby :: rails console destroy all 
Ruby :: generate dates using period rails 
Ruby :: deep copy and shallow copy in ruby 
Ruby :: ruby array with unique values 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =