*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 forgotten owner//// Created by Ma C on 16/3/26.// Copyright 2016 Xubaoaichiyu. All rights reserved.//#import "ViewController.h" @interface Viewcontroller () @property (weak, nonatomic) Iboutlet UIButton *foodone; @property (weak, nonatomic) Iboutlet UIButton *foodtwo; @end @implementation viewcontroller-(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)