当前位置: 首页 > news >正文

网站界面设计的基本原则是什么网页设计作业成品免费下载

网站界面设计的基本原则是什么,网页设计作业成品免费下载,电商平台模板,沈阳城市建设学院官方网站在iOS的开发过程中#xff0c;tableView的使用永远都是最常用的控件。今天学习了一下tableViewCell的操作。代码并不是很复杂#xff0c;如果有OC开发经验的人#xff0c;应该很容易看懂的。 class ViewController: UIViewController ,UITableViewDelegate, UITableViewData…在iOS的开发过程中tableView的使用永远都是最常用的控件。今天学习了一下tableViewCell的操作。代码并不是很复杂如果有OC开发经验的人应该很容易看懂的。 class ViewController: UIViewController ,UITableViewDelegate, UITableViewDataSource { // 因为Swift中要求变量或常量在声明时就要初始化其值所以我们在实际开发中声明变量或常量时使用可选类型。后面代码中使用到以上变量时需要加 ! 对其解包。var tableView : UITableView? // var items :NSMutableArray?// 例如可以不用可选var items :NSMutableArray []var leftBtn:UIButton?override func viewDidLoad() {super.viewDidLoad()self.items NSMutableArray()// 初始化tableViewsetupViews()// 右边添加按钮setupRightBarButtonItem()// 左边删除按钮setupLeftBarButtonItem();}func setupViews(){self.tableView UITableView(frame:self.view!.frame)self.tableView!.delegate selfself.tableView!.dataSource selfself.tableView!.registerClass(UITableViewCell.self, forCellReuseIdentifier: cell)self.view.addSubview(self.tableView!)}func setupLeftBarButtonItem(){self.leftBtn UIButton(type: UIButtonType.Custom)self.leftBtn!.frame CGRectMake(0,0,50,40)self.leftBtn!.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)self.leftBtn!.setTitle(Edit, forState: UIControlState.Normal)self.leftBtn!.tag 100self.leftBtn!.userInteractionEnabled falseself.leftBtn!.addTarget(self, action: leftBarButtonItemClicked, forControlEvents: UIControlEvents.TouchUpInside)let barButtonItem UIBarButtonItem(customView: self.leftBtn!)self.navigationItem.leftBarButtonItem barButtonItem}func setupRightBarButtonItem(){let barButtonItem UIBarButtonItem(title: Add, style: UIBarButtonItemStyle.Plain, target: self, action: rightBarButtonItemClicked)self.navigationItem.rightBarButtonItem barButtonItem}func rightBarButtonItemClicked(){let row self.items.countlet indexPath NSIndexPath(forRow:row,inSection:0)self.items.addObject(1)self.tableView?.insertRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Left)self.leftBtn!.userInteractionEnabled true}func leftBarButtonItemClicked(){if (self.leftBtn!.tag 100){// 设置当前tableView可编辑self.tableView?.setEditing(true, animated: true)self.leftBtn!.tag 200self.leftBtn?.setTitle(Done, forState: UIControlState.Normal)}else{self.tableView?.setEditing(false, animated: true)self.leftBtn!.tag 100self.leftBtn?.setTitle(Edit, forState: UIControlState.Normal)}}override func didReceiveMemoryWarning() {super.didReceiveMemoryWarning()// Dispose of any resources that can be recreated.}func tableView(tableView: UITableView, numberOfRowsInSection section: Int) - Int{return self.items.count}func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) - UITableViewCell{let cell tableView .dequeueReusableCellWithIdentifier(cell, forIndexPath: indexPath) as UITableViewCellcell.textLabel!.text String(format: %i, indexPath.row1)return cell}// 指定可编辑的行func tableView(tableView: UITableView, setEditing indexPath: NSIndexPath) - Bool{return true}// 编辑完成func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath){self.items.removeObjectAtIndex(indexPath.row)self.tableView?.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top)if (self.items.count 0){self.leftBtn!.userInteractionEnabled false}}// 编辑样式func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) - UITableViewCellEditingStyle{return (UITableViewCellEditingStyle.Delete)}// 指定哪些行可以移动func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) - Bool{return true}// 移动完成func tableView(tableView: UITableView, moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath){self.tableView?.moveRowAtIndexPath(sourceIndexPath, toIndexPath: destinationIndexPath)self.items.exchangeObjectAtIndex(sourceIndexPath.row, withObjectAtIndex: destinationIndexPath.row)}// 限制在同一分区移动func tableView(tableView: UITableView, targetIndexPathForMoveFromRowAtIndexPath sourceIndexPath: NSIndexPath, toProposedIndexPath proposedDestinationIndexPath: NSIndexPath) - NSIndexPath {if sourceIndexPath.section proposedDestinationIndexPath.section {return proposedDestinationIndexPath}return sourceIndexPath}// 点击cellfunc tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){print(row %d,indexPath.row)}}转载于:https://www.cnblogs.com/wangxianggudu/p/5107733.html
http://www.zqtcl.cn/news/540744/

相关文章:

  • 网站手机版模板做拼货商城网站
  • wordpress建自己的网站吗c2c网站的特点
  • 建设网站的成本有哪些龙岩做网站哪家最好
  • wordpress 多站点 子目录安徽望江县城乡建设局官方网站
  • 电子政务网站建设的步骤一般为俱乐部logo免费设计在线生成
  • 网站建设尚品男生学计算机哪个专业最吃香
  • app制作网站收费吗重庆网站产品推广
  • 网站开发预算怎么算厦门建站比较好的公司
  • 涡阳网站优化建设工程公司企业文化
  • 曲靖市住房和城乡建设局网站罗湖区网站公司
  • 购物券网站怎么做wordpress+好用插件
  • 商务网站建设的一般流程是什么?南宁seo费用服务
  • 做企业网站需要什么seminar是什么意思
  • 如何把代码放在网站首页教程深圳建网站哪个公
  • 做的网站第二年续费多钱上传到服务器的网站打开是空白
  • 网站建设花多少钱怎样建移动网站
  • 关键词排名优化网站上海有几个区分别叫什么名字
  • php网站开发基础定制自己的软件
  • 私人装修接单网站wordpress热门文章插件
  • 湘潭网站外包公司宁波妇科医生推荐
  • 企业网站建设可以分为几个层次三亚网站定制
  • 手机网站可以做商城吗如何为公司建立网站
  • 淄博建设银行网站怎么做盗号网站手机
  • 网站建设推广的10种方法精美个人网站
  • 西安专业承接网站搭建模板网站聚合页
  • 便宜网站建设加盟推广公司
  • 手机移动端网站怎么做三维建设项目管理网站
  • 如何把网站设为正确建设中广东学校网站建设公司
  • 企业型网站建设怎样收费dw制作网站模板
  • 自适应网站欣赏医联体网站建设