解析iOS应用的UI开发中懒加载和xib的简单使用方法

2020-01-14 18:19:35王振洲

三、对xib进行连线示例

1.连线示例

新建一个xib对应的视图类,继承自Uiview

解析iOS应用的UI开发中懒加载和xib的简单使用方法

在xib界面右上角与新建的视图类进行关联

解析iOS应用的UI开发中懒加载和xib的简单使用方法

把xib和视图类进行连线

解析iOS应用的UI开发中懒加载和xib的简单使用方法

注意:在使用中把weak改成为强引用。否则...

2.连线后的代码示例

YYViewController.m文件代码如下:

复制代码
//
//  YYViewController.m
//  10-xib文件的使用
//
//  Created by apple on 14-5-24.
//  Copyright (c) 2014年 itcase. All rights reserved.
//

 

#import "YYViewController.h"
#import "YYapp.h"
#import "YYappview.h"

@interface YYViewController ()
@property(nonatomic,strong)NSArray *app;
@end


复制代码
@implementation YYViewController

 

//1.加载数据信息
-(NSArray *)app
{
    if (!_app) {
        NSString *path=[[NSBundle mainBundle]pathForResource:@"app.plist" ofType:nil];
        NSArray *temparray=[NSArray arrayWithContentsOfFile:path];