《IOS开发系列教程》Action和Outlet

《IOS开发系列教程》Action和Outlet

 

Outlet: ViewController talks to View by using Outlet. Any object (UILabel, UIButton, UIImage, UIView etc) in View can have an Outlet connection to ViewController. Outlet is used as @property in ViewController which means that:
– you can set something (like Update UILabel's text, Set background image of a UIView etc.) of an object by using outlet.
– you can get something from an object (like current value of UIStepper, current font size of a NSAttributedString etc.)

Action: View pass on messages about view to ViewController by using Action (Or in technical terms ViewController set itself as Target for any Action in View). Action is a Method in ViewController (unlike Outlet which is @property in ViewController). Whenever something (any Event) happens to an object (like UIbutton is tapped) then Action pass on message to ViewController. Action (or Action method) can do something after receiving the message.
Note: Action can be set only by UIControl's child object; means you can't set Action for UILabel, UIView etc.

 

 

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章转载自:IT夜班车,否则按侵权处理.

    分享到:

留言

你的邮箱是保密的 必填的信息用*表示