*owner is now very seldom used in the development of interested children's shoes can see *
We meet owner usually in a similar
[[[NSBundle Mainbundle] loadnibnamed:@ "food" Owner:nil Options:nil]lastobject] encountered.
Our general practice is to set owner to self (usually when I customize the cell).
But when defining other controls, we need to think about why, or what we need to be aware of.
Here I begin to introduce owner.
First look at the contents of the GIF below:
It is not difficult to find that I am trying to drag the space is not successful, this is why???
Next look at the gif below
We dragged the control to success (Note * Here is why there is less use of owenr now, because the coupling of the line set is not good for improving coding efficiency)
Easy to use:
////VIEWCONTROLLER.M//CX is the owner of the forgotten////Created by Ma C on 16/3/26.//copyright©2016 year Xubaoaichiyu. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () @property (weak, nonatomic) Iboutlet UIButton*Foodone, @property (weak, nonatomic) Iboutlet UIButton*Foodtwo;@end@implementationViewcontroller-(Ibaction) Foodoneaction: (ID) Sender {NSLog (@"Foodone"); }-(Ibaction) Foodtwoaction: (ID) Sender {NSLog (@"Foodtwo");}- (void) viewdidload {[Super viewdidload]; Self.view= [[[[NSBundle Mainbundle] loadnibnamed:@" Food"owner:self options:nil]lastobject];}@end
IOS Miscellaneous Pen-14 (owner forgotten)