斯坦福Developing iOS 8 Apps学习笔记(六)

来源:互联网 发布:医生都善良知乎 编辑:程序博客网 时间:2024/05/21 09:30

UITextField

一些基本属性

  • becomeFirstResponder
  • resignFirstResponder
  • Return Key被按下时func textFieldShouldReturn(sender:UITextField) -> Bool一般需要sender.resignFirstResponder
  • textField resin firstResponder时func textFieldDidEndEditing(sender:UITextField)
  • clearOnBeginEditing:Bool
  • adjustsFontSizeToFitWidth
  • minimumFontSize(一般如果使用上面一个,则要设置这个)
  • placeholder
  • background/disabledBackground
  • defaultTextAttributes //apply to entire text
  • **UITextField在左右各有一个overlays,you can control in detail the layout of the text field(border, left/right view, clear button)
  • var inputAccessoryView:UIView //UITextField method,加强键盘,能够在键盘上方创建一个view

对于输入的一些设置

由UITextField遵守UITextInputTraitsPropotocol
- var UITextAutoCapitalizationType // words,sentences,etc.
- var UITextAutoCorrectionType // yes or no
- var UIReturnKeyType // Go,Search,Google,Done…
- var Bool secureTextEntry
- var UIKeyboardType //ASCII,URL,PhonePad,etc.

键盘输入的可以监听的时事件

  • UIKeyboard{will,did}{show,hide}Notifications sent by UIWindow
  • 监听方法:
  • NSNotificationCenter.defaultCenter().addObserver(self, selector:"theKeyboardAppeared:", name:UIKeyboardDidShowNotification, object:view.window)
  • notification.userInfo have the details about appearance
  • 一般需要在此时控制使要输入的目标能够显示在键盘的上方
  • UITableViewController listens for this and scrolls automatically

Table View

一些基本属性

  • var tableHeaderView:UIView
  • var tableFooterView:UIView

UITableViewDataSource


  • tableView(UITableView, titleForHeaderInSection:Int)
  • tableView(UITableView, titleForFooterInSection:Int)
  • tableView(UITableView, cellForRowAtIndexPath:NSIndexPath)

dataSource主要是显示什么,Delegate主要是怎么显示

UITableViewDelegate

  • tableView didselectRowAtIndexPath
  • tableView accessoryButtonTappedForRowWithIndexPath
  • will/did Select
  • view For Header/Footer
  • will begin/did end notifications for editing

tableView

  • readloadData()
  • reloadRowsAtIndexPaths

height of rows

  • Row height can be fixed (rowHeight:CGFloat)
  • rowHeight = UITableViewAutomaticDimension // uses AutoLayout
  • help tableView by setting estimatedRowHeight
  • tableView heightForRowAtIndexPath -> CGFloat //这个会被调用a lot
  • tableView estimatedHeightForRowAtIndexPath -> CGFloat
tableView.estimatedRowHeight = tableView.rowHeighttableView.rowHeight = UITableViewAutomaticDimension
0 0
原创粉丝点击