大佬教程收集整理的这篇文章主要介绍了如何获得类似于iOS的本机Mail应用程序的删除功能,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
override func tableView(tableView: UITableView,editActionsForRowATindexPath indexPath: NSIndexPath) -> [UITableViewRowAction]?
但我无法弄清楚使用什么来使按钮扩展到表格单元格的整个宽度.有什么想法吗?
创建一个UIScrollView并将其作为子视图添加到UITableViewCell
(还要添加大小约束以使scrollview的大小与其父边界相同)
现在为scrollview设置此代码:
//set scroll view scrollview.delegate = self; scrollview.pagingEnabled = true; scrollview.showsHorizontalScrollInDicator = false; scrollview.showsVerticalScrollInDicator = false; scrollview.contentSize.width = scrollview.bounds.width * 2.0; //create delete swipe view let deleteButton = UIView(frame: CGRectMake(scrollview.bounds.width,scrollview.bounds.width * 2.0,scrollview.bounds.height)) deleteButton.BACkgroundColor = UIColor.redColor() let deleteLabel = UILabel(frame: CGRectMake(0,scrollview.bounds.width * 0.3,scrollview.bounds.height)) deleteLabel.textColor = UIColor.whiteColor() deleteLabel.text = "delete" deleteLabel.contentMode = .Center deleteLabel.textAlignment = .Center deleteButton.addSubview(deleteLabel) scrollview.addSubview(deleteButton)
现在委托功能:
func scrollViewDidEndDecelerating(scrollView: UIScrollView) { if scrollView.contentOffset.x == 0{ return; } let confirmdelete = UIAlertController(title: "Are you sure you want to delete?",message: nil,preferredStyle: UIAlertControllerStyle.ActionSheet) confirmdelete.addAction(UIAlertAction(title: "Yes",style: UIAlertActionStyle.Destructive,handler: { (_) -> Void in //delete confirmed })) confirmdelete.addAction(UIAlertAction(title: "Cancel",style: UIAlertActionStyle.Cancel,handler: { (_) -> Void in scrollView.contentOffset.x = 0; })) rootViewController.presentViewController(confirmdelete,animated: true,completion: nil); }
以上是大佬教程为你收集整理的如何获得类似于iOS的本机Mail应用程序的删除功能全部内容,希望文章能够帮你解决如何获得类似于iOS的本机Mail应用程序的删除功能所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。