IOS miscellaneous-14 (forgotten owner), ios-14

Source: Internet
Author: User

IOS miscellaneous-14 (forgotten owner), ios-14

* The owner has rarely used any children's shoes during development. You can check them out *

We often encounter a similar

[[NSBundle mainBundle] loadNibNamed: @ "Food" owner: nil options: nil] lastObject.

The general practice is to directly set the owner to self (usually when the cell is customized ).

But when defining other controls, we need to think about why, or what else needs attention.

Next I will introduce the owner.

Observe the following gif content carefully:

It is not difficult to find that the space I am trying to drag is unsuccessful. Why ???

Next, let's take a look at the gif below.

We drag the control successfully (note * here is why the number of owenr applications is getting fewer and fewer, because of the high coupling row sets, which is not suitable for improving the encoding efficiency)

Simple application:

//// ViewController. m // the owner that CX has forgotten // 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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.