iOS开发的UI制作中动态和静态单元格的基本使用教程

2020-01-14 17:39:10王冬梅


视图部分

 

 YYappCell.h文件

复制代码
//
//  YYappCell.h
//  01-使用动态单元格来完成app应用程序管理界面的搭建
//
//  Created by 孔医己 on 14-6-2.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

 

#import <UIKit/UIKit.h>


@class YYappInfo,YYappCell;

@protocol YYappCellDelegate <NSObject>
-(void)btnDidClick:(YYappCell *)cell;


@end
@interface YYappCell : UITableViewCell

@property(nonatomic,strong)YYappInfo *app;
//@property(nonatomic,strong)YYViewController *controller;
@property(nonatomic,strong)id <YYappCellDelegate> delegate;

@end


YYappCell.m文件
复制代码
//
//  YYappCell.m
//  01-使用动态单元格来完成app应用程序管理界面的搭建
//
//  Created by 孔医己 on 14-6-2.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

 

#import "YYappCell.h"
#import "YYappInfo.h"

@interface YYappCell ()
@property (weak, nonatomic) IBOutlet UIImageView *appimg;

@property (weak, nonatomic) IBOutlet UILabel *apptitle;
@property (weak, nonatomic) IBOutlet UILabel *appdownload;
@property (weak, nonatomic) IBOutlet UIButton *appbtn;

@end


复制代码
@implementation YYappCell

 


-(void)setApp:(YYappInfo *)app
{
    _app=app;
    self.apptitle.text=_app.name;
    self.appdownload.text=[NSString stringWithFormat:@"大小 %@ | 下载量 %@次",_app.size,_app.download];
    self.appimg.image=[UIImage imageNamed:_app.icon];
    
}

#pragma mark- 完成按钮点击事件

- (IBAction)btnOnclick:(UIButton *)sender
{
    //按钮被点击后,变为不可用状态