UI基础-day05-Shopping-08Xib-09商品的增加和删除功能

UI基础-day02-Shopping-01搭建商城基本框架
UI基础-day02-Shopping-02添加一个商品
UI基础-day02-Shopping-03九宫格排序
UI基础-day02-Shopping-04优化添加和删除功能
UI基础-day02-Shopping-05加载数据
UI基础-day02-Shopping-06懒加载-1基础
UI基础-day03-Shopping-06懒加载-2Plist文件读取
UI基础-day03-Shopping-06懒加载-3字典转模型
UI基础-day04-Shopping-07自定义控件-01设置子控件的frame
UI基础-day04-Shopping-07自定义控件-02加载数据
UI基础-day04-Shopping-07自定义控件-03初始化和类方法
UI基础-day04-Shopping-08Xib-01基本使用
UI基础-day04-Shopping-08Xib-02简单的加载数据
UI基础-day04-Shopping-08Xib-03Tag值方式加载数据
UI基础-day04-Shopping-08Xib-04自定义Xib控件
UI基础-day04-Shopping-08Xib-05自定义Xib控件-优化
UI基础-day04-Shopping-08Xib-06Xib使用注意
UI基础-day05-Shopping-08Xib-07转换为代码的分析
UI基础-day05-Shopping-08Xib-08回顾Xib自定义类

效果图

脑图

部分代码,点击➕按钮

.... 
-(void)btnAddViewClick{
    NSUInteger shopIndex = self.shopView.subviews.count;//当前商品索引
    HUHShopModel * shopM = self.shopDataArray[shopIndex];//获取封装好的数据模型
    HUHShopView * shopXib = [HUHShopView shopViewWithShop:shopM];//实例化包含数据的Xib
    
    CGFloat shopW = shopXib.frame.size.width;   //商品的宽度
    CGFloat shopH = shopXib.frame.size.height;  //商品的高度
    
    //九宫格排序
    [self nineGridSort:shopXib columnMax:3 shopWith:shopW shopHeight:shopH spaceY:14];
    [self.shopView addSubview:shopXib];
    
    //控制按钮的状态
    //只要点击'➕',按钮'➖'就为可用
    self.btnRemove.enabled = YES;
    if(self.shopView.subviews.count >= self.shopDataArray.count){
        self.btnAdd.enabled = NO;
    }
}
....

你可能感兴趣的:(UI基础-day05-Shopping-08Xib-09商品的增加和删除功能)