Detecting which UIButton was pressed in a UITableView

前端 未结 26 2954
小蘑菇
小蘑菇 2020-11-22 00:40

I have a UITableView with 5 UITableViewCells. Each cell contains a UIButton which is set up as follows:

- (UITableView         


        
26条回答
  •  别那么骄傲
    2020-11-22 01:08

    Note here i am using custom cell this code is perfectly working for me

     @IBAction func call(sender: UIButton)
        {
            var contentView = sender.superview;
            var cell = contentView?.superview as EmployeeListCustomCell
            if (!(cell.isKindOfClass(EmployeeListCustomCell)))
            {
                cell = (contentView?.superview)?.superview as EmployeeListCustomCell
            }
    
            let phone = cell.lblDescriptionText.text!
            //let phone = detailObject!.mobile!
            let url:NSURL = NSURL(string:"tel://"+phone)!;
            UIApplication.sharedApplication().openURL(url);
        }
    

提交回复
热议问题