ios - Displaying an alert on a new View Controller -


i have button sends me on view controller. trying display alert on next view controller.

in viewdidload() method of new controller, create new uialertcontroller , display following

let alertcontroller = uialertcontroller(title: "default style", message: "a standard alert.", preferredstyle: .alert)  let cancelaction = uialertaction(title: "cancel", style: .cancel) { (action) in     // ... } alertcontroller.addaction(cancelaction)  let okaction = uialertaction(title: "ok", style: .default) { (action) in     // ... } alertcontroller.addaction(okaction)  self.presentviewcontroller(alertcontroller, animated: true) {     // ... } 

note example taken nshipster website offers nice articles ios. can find article uialertcontroller here. explain other stuff can class, display action sheet example.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -