本项目是《beginning iOS8 programming with swift》中的项目学习笔记==》全部笔记目录

------------------------------------------------------------------------------------------------------------------

Self Sizing Cell的设置通常有如下三个主要步骤:

找到DetailView的界面,在prototype cell中添加auto layout约束
指定TableView的estimated row height
设置row height为UITableViewAutomaticDimention
 
1.    修改Restaurant中的locaiton为全名(用很长的名称,使得一行显示不下):

var restaurants = [
Restaurant(name: "Cafe Deadend", type: "Coffee & Tea Shop", location: "G/F, 72 Po Hing Fong, Sheung Wan, Hong Kong", image: "cafedeadend.jpg", isVisited: false),
Restaurant(name: "Homei", type: "Cafe", location: "Shop B, G/F, 22-24A Tai Ping San Street SOHO, Sheung Wan, Hong Kong", image: "homei.jpg", isVisited: false),
Restaurant(name: "Teakha", type: "Tea House", location: "Shop B, 18 Tai Ping Shan Road SOHO, Sheung Wan, Hong Kong", image: "teakha.jpg", isVisited: false),
Restaurant(name: "Cafe loisl", type: "Austrian / Causual Drink", location: "Shop B, 20 Tai Ping Shan Road SOHO, Sheung Wan, Hong Kong", image: "cafeloisl.jpg", isVisited: false),
Restaurant(name: "Petite Oyster", type: "French", location: "24 Tai Ping Shan Road SOHO, Sheung Wan, Hong Kong", image: "petiteoyster.jpg", isVisited: false),
Restaurant(name: "For Kee Restaurant", type: "Bakery", location: "Shop J-K., 200 Hollywood Road, SOHO, Sheung Wan, Hong Kong", image: "forkeerestaurant.jpg", isVisited: false),
Restaurant(name: "Po's Atelier", type: "Bakery", location: "G/F, 62 Po Hing Fong, Sheung Wan, Hong Kong", image: "posatelier.jpg", isVisited: false),
Restaurant(name: "Bourke Street Backery", type: "Chocolate", location: "633 Bourke St Sydney New South Wales 2010 Surry Hills", image: "bourkestreetbakery.jpg", isVisited: false),
Restaurant(name: "Haigh's Chocolate", type: "Cafe", location: "412-414 George St Sydney New South Wales", image: "haighschocolate.jpg", isVisited: false),
Restaurant(name: "Palomino Espresso", type: "American / Seafood", location: "Shop 1 61 York St Sydney New South Wales", image: "palominoespresso.jpg", isVisited: false),
Restaurant(name: "Upstate", type: "American", location: "95 1st Ave New York, NY 10003", image: "upstate.jpg", isVisited: false),
Restaurant(name: "Traif", type: "American", location: "229 S 4th St Brooklyn, NY 11211", image: "traif.jpg", isVisited: false),
Restaurant(name: "Graham Avenue Meats", type: "Breakfast & Brunch", location: "445 Graham Ave Brooklyn, NY 11211", image: "grahamavenuemeats.jpg", isVisited: false),
Restaurant(name: "Waffle & Wolf", type: "Coffee & Tea", location: "413 Graham Ave Brooklyn, NY 11211", image: "wafflewolf.jpg", isVisited: false),
Restaurant(name: "Five Leaves", type: "Coffee & Tea", location: "18 Bedford Ave Brooklyn, NY 11222", image: "fiveleaves.jpg", isVisited: false),
Restaurant(name: "Cafe Lore", type: "Latin American", location: "Sunset Park 4601 4th Ave Brooklyn, NY 11220", image: "cafelore.jpg", isVisited: false),
Restaurant(name: "Confessional", type: "Spanish", location: "308 E 6th St New York, NY 10003", image: "confessional.jpg", isVisited: false),
Restaurant(name: "Barrafina", type: "Spanish", location: "54 Frith Street London W1D 4SL United Kingdom", image: "barrafina.jpg", isVisited: false),
Restaurant(name: "Donostia", type: "Spanish", location: "10 Seymour Place London W1H 7ND United Kingdom", image: "donostia.jpg", isVisited: false),
Restaurant(name: "Royal Oak", type: "British", location: "2 Regency Street London SW1P 4BZ United Kingdom", image: "royaloak.jpg", isVisited: false),
Restaurant(name: "Thai Cafe", type: "Thai", location: "22 Charlwood Street London SW1V 2DY Pimlico", image: "thaicafe.jpg", isVisited: false)
]

2. 设置Detail视图中表格的两个Label控件水平居中、Name距离左边距9点、Value距离左边距87点,距离右边距10点(最好先Reset to suggested constrain)。
3. 在Detail的viewDidLoaded方法中:

tableView.estimatedRowHeight = 36.0
tableView.rowHeight = UITableViewAutomaticDimension

4. 选中Value Label,设置行数为0,否则不会换行。

同理,对Restaurant控制器中的控件进行设置。

效果图:

最新文章

  1. PPTP协议
  2. 递推 N循环问题
  3. Delphi中使用@取函数地址的问题(转)
  4. Iframe跨域Session丢失的问题
  5. list笔记总结
  6. Android开发之onActivityResult()中的resultCode为0,intent为null的解决办法
  7. HDOJ2002计算球体积
  8. 百度地图API 添加自定义标注 多点标注
  9. module_param()函数
  10. ffmpeg转换参数和压缩输出大小的比率 参考 最新版本FFMPEG
  11. linux的dd命令
  12. Matlab小波工具箱的使用2
  13. 帝国cms系统限制的登录次数不得超过5次请等60分钟过后方可重新登录
  14. 编译centos6.5:glibc 升级2.14问题
  15. drop解决过拟合的情况
  16. 用户管理_组管理_权限管理.ziw
  17. 纯css3实现的超炫checkbox复选框和radio单选框
  18. FTP和TCP、UDP
  19. Bin Packing 装箱问题——NPH问题的暴力枚举 状压DP
  20. 开源一款android 偷拍 app【静拍】豌豆荚、flyme商店已经上线

热门文章

  1. mongodb--与spring整合
  2. Busybox下mdev配置说明
  3. TCP连接与关闭
  4. AngularJS跨域请求
  5. Hive UDF’S addMonths
  6. JAVA版Kafka代码及配置解释
  7. TopCoder SRM 633 Div.2 500 Jumping
  8. 安全框架 - Shiro与springMVC整合的注解以及JSP标签
  9. 每日学习心得:UEditor样式被过滤无法显示问题
  10. github结合TortoiseGit使用sshkey,无需输入账号和密码