ios - blank screen appears when click on UILabel in swift -
i'm trying open iphone call screen selected number when click on uilabel hyperlink in swift.
a blank screen appears 1 second , goes. no iphone call screen appears. don't know wrong in code.
code in viewdidload
let strphone = "080 2854 2105" let attributedphonestr = nsmutableattributedstring(string:strphone, attributes:[nslinkattributename: nsurl(string: "http://aerospace.honeywell.com")!]) lblphonecontact.attributedtext = attributedphonestr lblphonecontact.userinteractionenabled = true let gesturerecognizer = uitapgesturerecognizer(target: self, action: selector("labelpressed")) lblphonecontact.addgesturerecognizer(gesturerecognizer)
function labelpressed
func labelpressed() { let url:nsurl = nsurl(string: "tel://08028542105")! uiapplication.sharedapplication().openurl(url) }
what wrong or missing in code. tried running on iphone device.
for swift use
let url:nsurl = nsurl(string: "telprompt:08028542105")!
instead of
let url:nsurl = nsurl(string: "tel://08028542105")!
Comments
Post a Comment