Thursday, September 22, 2016

Calling action & Mail action in tableview in swift




@IBAction func locationphoneTapped(sender: UITapGestureRecognizer)
    {
        let tapLocation = sender.locationInView(self.tableView)
        //using the tapLocation, we retrieve the corresponding indexPath
        let indexPath = self.tableView.indexPathForRowAtPoint(tapLocation)
        let s3 = self.resultArray[(indexPath?.section)!] .valueForKey("PhoneNumber") as? String
        let phoneNumber: String = "telprompt://".stringByAppendingString(s3!)
        UIApplication.sharedApplication().openURL(NSURL(string: phoneNumber)!)
    }
    
    @IBAction func locationMailAction(sender: UITapGestureRecognizer)
    {
        let email = self.locationArray[0].valueForKey("EmailID") as? String
        let phoneNumber: String = "mailto://".stringByAppendingString(email!)
        let url = NSURL(string: phoneNumber)
        UIApplication.sharedApplication().openURL(url!)

    }




No comments:

Post a Comment