仿米折网app


右边是仿左边的界面:

           代码下载链接 :点击打开链接

         




test测试单个页面中出现的问题:

2014-11-23 12:49:27.377 Test[1736:60b] Application tried to push a nil view controller on target <UINavigationController: 0x8da5d50>.
2014-11-23 12:49:29.766 Test[1736:60b] ===¥ 45.00====
2014-11-23 12:49:29.767 Test[1736:60b] -[__NSCFString setText:]: unrecognized selector sent to instance 0x8ddf1e0


<span style="color:#ff0000;">//  实质不是label  而是一个字符串 !!!  __NSCFString

                        同样的错误不要再犯两次!!!!!!</span>




@interface RootViewController : UITabBarController

@end

@impleament

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    //底部 tabbar 透明位置的背景色,默认为蓝色,需定制颜色
    // 设置 tabbar
    [[UITabBar appearance] setTintColor:[UIColor orangeColor]];
    
    NSMutableArray *nvcArr = [NSMutableArray array];
    NSArray *classArr = [NSArray arrayWithObjects:@"ShouYeViewController", @"TeMaiViewController",@"10GouViewController", @"YouHuiPinViewController",@"WoDeViewController", nil];
    
    UIViewController *vc = nil;
    UINavigationController *nvc = nil;
    
    for (int i = 0; i < classArr.count; i++) {
        
        //根据类名,循环创建图标,省代码!!!
        vc = [[NSClassFromString([classArr objectAtIndex:i]) alloc] init];
        nvc = [[UINavigationController alloc] initWithRootViewController:vc];
        
               //设置navigationbar
        [nvc.navigationBar setBarTintColor:[UIColor orangeColor]];
        
        // 这样设置navigationbar 无效!!!!
        //nvc.navigationController.navigationBar.backgroundColor = [UIColor orangeColor];
        
        
        [nvcArr addObject:nvc];
    }
    
    self.viewControllers = nvcArr;
}

@end


// 设置_tableview 分割线的颜色

_tableView.separatorColor = [UIColor clearColor];


内存占用太大的问题:

起初以为是 //cell.model = model; 有问题     ,蓝色部分是问题所在,被修改掉的代码


@implementation TeMaiViewController

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIde = @"cellID";
    TeMaiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIde];
    if (!cell) {
        cell = [[TeMaiTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIde];
    }
    
    TeMaiModel *model = [_modelsArray objectAtIndex:indexPath.row];
    
    <span style="color:#33cc00;">//cell.model = model;  //这样设置也不会消耗很多内存,没有创建新的对象,但最好不要这样做</span>
    
    cell.topIconUrl = model.topIconUrl;
    cell.topLabelText = model.topLabelText;
    cell.topSubLabelText = model.topSubLabelText;
    cell.topEndLabelText = model.topEndLabelText;
    cell.imagesArray = model.imagesArray;
    cell.labelsArray = model.labelsArray;
    return cell;
}

@end


@interface TeMaiTableViewCell : UITableViewCell

@property (nonatomic,copy) NSString *topIconUrl;
@property (nonatomic,copy) NSString *topLabelText;
@property (nonatomic,copy) NSString *topSubLabelText;
@property (nonatomic,copy) NSString *topEndLabelText;

@property (nonatomic,retain) NSMutableArray *imagesArray;
@property (nonatomic,retain) NSMutableArray *labelsArray;

<span style="color:#33cc00;">//@property (nonatomic,retain) TeMaiModel *model;</span>

@end


@implementation TeMaiTableViewCell

-(void)setModel:(TeMaiModel *)model
{
    <span style="color:#ff0000;">//消耗内存
    //_model = [[TeMaiModel alloc] init];</span>
    //_model = model;
    
    [_topIconView setImageWithURL:[NSURL URLWithString:model.topIconUrl]];
    _topNameLabel.text = model.topLabelText;
    
    float discount = [model.topSubLabelText floatValue]/10;
    _topSubLabel.text = [NSString stringWithFormat:@"%.1f折起",discount];
    
    if ([model.topEndLabelText isEqualToString:@"2"]) {
        _topEndLabel.text = @"new";
    }else{
        _topEndLabel.text = @"old";
    }
    
    UIImageView *imgView = nil;
    UILabel *priceLabel = nil;
    
    for (int i = 0; i < 3; i++) {
        
        if (_imagesArr.count > i) {
            
            NSString *imageName = (i == 0)? @"default_big.jpg":@"default_small.jpg";
            
            imgView = (UIImageView*)[_imagesArr objectAtIndex:i];
            [imgView setImageWithURL:[NSURL URLWithString:model.imagesArray[i]] placeholderImage:[UIImage imageNamed:imageName]];
            //[imgView setImageWithURL:[NSURL URLWithString:_model.imagesArray[i]]];
            
            priceLabel = (UILabel *)[_imageLabelsArr objectAtIndex:i];
            NSString *priceString = [NSString stringWithFormat:@"¥ %@",model.labelsArray[i]];
            
            priceLabel.text = priceString;
        }
    }
    
}

@end


尽管注释掉了alloc model  那句,但还是无法解决逐渐加载tableview,内存过大的问题



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值