📅  最后修改于: 2022-03-11 14:58:00.697000             🧑  作者: Mango
import Foundation
import SwiftUI
import UIKit
struct AnotherControllerView : UIViewControllerRepresentable {
typealias UIViewControllerType = AnotherController
func makeCoordinator() -> AnotherControllerView.Coordinator {
Coordinator(self)
}
func makeUIViewController(context: UIViewControllerRepresentableContext) -> AnotherController {
return AnotherController()
}
func updateUIViewController(_ uiViewController: AnotherController, context: UIViewControllerRepresentableContext) {
}
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")
}
}