so im a student and im cloning an app just to play around with Swift. I have a view that contains a button that, when pressed, goes to a different view with a sheet presentation. I was to add another button on that sheet view that also goes to another view but full screen.
so
first view button -> sheet button -> last view
the first button works fine, but on the sheet the button won't even print anything to the console when pressed. The first button (that works), was only added programmatically because I had an image in the background of the view with a fake button look, so I did not add a button with a frame or CG.
im guessing that is my issue since for the sheet button I am adding the button programmatically and the UI too.
this is the code for the button that doesnt work
//cashout button
cashOutBut.configuration = .filled()
cashOutBut.configuration?.baseBackgroundColor = .systemGreen
cashOutBut.configuration?.cornerStyle = .large
cashOutBut.titleLabel?.text = String("Cash Out")
cashOutBut.configuration?.title = String("Cash Out")
cashOutBut.isEnabled = true
//var config = UIButton.Configuration.filled()
//config.baseBackgroundColor = .green
view.addSubview(cashOutBut)
}
@IBAction func cashOutBut(_sender: Any){
let detailViewController = CashOutViewController()
let nav = UINavigationController(rootViewController: detailViewController)
nav.modalPresentationStyle = .fullScreen
(nav, animated: true, completion: nil)
}
the one that works is not added to the view/subview and is only
@IBAction func cashOut(_ sender: Any){
let detailViewController = SheetViewController()
let nav = UINavigationController(rootViewController: detailViewController)
nav.modalPresentationStyle = .pageSheet
if let sheet = nav.sheetPresentationController {
sheet.detents = [.medium(), .large()]
sheet.prefersScrollingExpandsWhenScrolledToEdge = false
sheet.preferredCornerRadius = 25// add
sheet.prefersGrabberVisible = true
}
present(nav, animated: true, completion: nil)
}
do I need to add a target or someting?