How can I display another view on my IOS app in SWift 3 from the action of Snackbar in IOS? I tried the following code(i.e As soon as the snackbar appear and I tap on the action part of the Snackbar then a new view of PatientViewController
should open with Id as PatientVC
) :
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
let message = MDCSnackbarMessage()
let action = MDCSnackbarMessageAction()
let actionhandler = {() in
let actionmessage = MDCSnackbarMessage()
actionmessage.text = "Button Click Success"
MDCSnackbarManager.show(actionmessage)
let storyboard = UIStoryboard(name: "Main", bundle: nil);
let vc = storyboard.instantiateViewController(withIdentifier: "PatientVC") as! PatientViewController;
self.navigationController?.pushViewController(vc, animated: true);
}
action.handler = actionhandler
action.title = "Done"
message.action = action
message.text = "Welcome"
MDCSnackbarManager.show(message)
}
where PateintVC
is the id and PatientViewController
is the name of the viewController
I want to display.But this is giving me error that EncounterFilterTableViewCell
has no member navigationController
. And as soon as I am inhereting UIViewController
along with the UITableViewCell
in my code. It is giving error that multiple inheretence from classes UITableViewCell
and UIviewController
.
What should be done so that I can display my view represented by PatientViewController
with ID PatientVC
. Below is the complete code of my class where I have my Snackbar code.
import UIKit
import MaterialComponents.MaterialSnackbar
class EncounterFilterTableViewCell: UITableViewCell{
@IBOutlet weak var filterCheckBox: CheckBox!
@IBOutlet weak var filterNameTextView: UITextView!
var filterIndex : [String : Int] = [
getDataFromAppLanguage("Final") + " " + getDataFromAppLanguage("Diagnosis") : 0,
getDataFromAppLanguage("Diagnosis") : 1,
getDataFromAppLanguage("Test") : 2,
getDataFromAppLanguage("Operation") : 3,
getDataFromAppLanguage("Drug") : 4,
getDataFromAppLanguage("Media") : 5,
getDataFromAppLanguage("FormsEn") : 6,
getDataFromAppLanguage("PatientEn") + " " + getDataFromAppLanguage("Status") : 7
]
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
@IBAction func filterBoxClicked(_ sender: AnyObject) {
EncounterFilterViewController.updateFilterStatus(filterIndex[filterNameTextView.text]!)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
let message = MDCSnackbarMessage()
let action = MDCSnackbarMessageAction()
let actionhandler = {() in
let actionmessage = MDCSnackbarMessage()
actionmessage.text = "Button Click Success"
MDCSnackbarManager.show(actionmessage)
let storyboard = UIStoryboard(name: "Main", bundle: nil);
let vc = storyboard.instantiateViewController(withIdentifier: "PatientVC") as! PatientViewController;
self.navigationController?.pushViewController(vc, animated: true);
}
action.handler = actionhandler
action.title = "Done"
message.action = action
message.text = "Welcome"
MDCSnackbarManager.show(message)
}
}