我有一个tableview,每个单元格都有一个按钮.当点击它时,我有一个didselectrow功能.我想使用我的indexpath从一个给出单元格内容的数组中获取一个值.如何将此NSIndexpath转换为要在数组中使用的int?
你最想要的是row属性.你可以看到一个
example here.
func tableView(tableView: UITableView!,didSelectRowAtIndexPath indexPath: NSIndexPath!) { let alert = UIAlertController(title: "Item selected",message: "You selected item \(indexPath.row)",preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "OK",style: UIAlertActionStyle.Default,handler: { (alert: UIAlertAction!) in println("An alert of type \(alert.style.hashValue) was tapped!") })) self.presentViewController(alert,animated: true,completion: nil) }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。