Swift - Dismissing Alert Message Closes View Controller
By : user3478908
Date : March 29 2020, 07:55 AM
will be helpful for those in need Remove self.dismissViewControllerAnimated(true, completion: nil) from your OK button UIAlertAction's handler. Alert is dismissed automatically upon OK button click and you're dismissing registration controller with this call.
|
Message notification when inside another view controller
By : Lu53
Date : March 29 2020, 07:55 AM
With these it helps Use APNS, I prefer the local notification,didReceiveLocalnotification method will get called,then display an alert Use delegate,assign delegate to the profile controller,and implement the required method,when you have a message arrived,display an alert
|
How to pass notification data to a View Controller with Swift
By : hipslim
Date : March 29 2020, 07:55 AM
hope this fix your issue There are lots of ways to handle this. You're already creating a view controller and installing it as the window's root view controller. code :
class QuestionViewController: UIViewController {
public var questionString: String = ""
@IBOutlet weak var questionLabel: UILabel!
override func viewWillAppear(_ animated: Bool) {
questionLabel.text = questionString
}
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
//Use a guard statement to make sure that userInfo is a String
guard let userInfo = response.notification.request.content.userInfo as? String else {
completionHandler()
return
}
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
// Print full message.
print(userInfo)
let storyboard = UIStoryboard(name:"Main", bundle:nil)
//If question_view is the correct type, set it's question_string property
if let question_view = storyboard.instantiateViewController(withIdentifier: "Question") as QuestionViewController {
questionString = userInfo
window?.rootViewController = question_view
completionHandler()
}
|
add a if condition to rails delete function and pass a alert message to view
By : Dev
Date : November 26 2020, 03:01 PM
Hope that helps The response of OdrOrderLine.where(prd_item_id: @items.id).pluck(:id) will always make the condition @item_odr!=null return true. First, it is important to note that null isn't a Ruby keyword, you probably want to use nil instead. This doesn't raise an error because there is no local variable null defined and therefore null simply returns nil. But this line might confuse to other developers. code :
def delete
@item = PrdItem.find(params[:id])
if OdrOrderLine.where(prd_item_id: @item.id).any?
flash[:notice] = "Cannot be deleted"
# ...
else
@item.destroy
# ...
|
How to pass data from UI Alert Controller to another view controller iOS
By : Aleksandar Paunovic
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Im working on scanning attendance app. a bit confuse on how to open another view controller through alert view. , You can do like this: code :
let actionSheet = UIAlertController (title: "Please Confirm Before Scan", message: "messageToShow", preferredStyle: .alert)
let okaction = UIAlertAction(title: "Proceed to Scan", style: .default) { (action) in
gotoFouthViewController(/*add argument if needed*/)
}
let cancelaction = UIAlertAction(title: "Reselect", style: .cancel) { (action) in
//cancel the alert
}
actionSheet.addAction(okaction),
actionSheet.addAction(cancelaction),
present(actionSheet, animated: true, completion: nil)
func gotoFouthViewController(argument) {
//push or present the fourth view controller here
}
|