关于ios内存警告

for (int i=0; i<pageArr.count; i++) {

        //创建纵向的scorllow

        

        

        

        

        sv1 = [[UIScrollView alloc] initWithFrame:CGRectMake(ScreenWidth*i, 0, ScreenWidth, ScreenHeight)];

        sv1.bounces = YES;

        sv1.pagingEnabled = YES;

        sv1.tag = 100+i;

        sv1.showsVerticalScrollIndicator=NO;

        

        

        

        NSArray *blockArray=[pageDic objectForKey:pageArr[i]];

        

        

        

      

        

        

        for (int j=0; j<blockArray.count; j++) {

            //设置纵向ScrollView的高度

            sv1.contentSize = CGSizeMake(ScreenWidth, ScreenHeight*blockArray.count);

            

            //设置静态层图片

            imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,ScreenHeight*j, ScreenWidth, ScreenHeight)];

            imageView.contentMode=UIViewContentModeScaleAspectFill;

            imageView.userInteractionEnabled = YES;

            NSString * imageName = [[NSBundle mainBundle] pathForResource:blockArray[j] ofType:nil];

            imageView.image = [UIImage imageWithContentsOfFile:imageName];

            

            

            NSArray *dynamicArr=[blockDic objectForKey:blockArray[j]];//动态交互

            

            //纵向动态ScrollView

            sv2= [[UIScrollView alloc] initWithFrame:CGRectMake(0, ScreenHeight*j, ScreenWidth, ScreenHeight)];

            sv2.bounces = YES;

            sv2.pagingEnabled = YES;

            sv2.tag = 100+i;

            sv2.showsVerticalScrollIndicator=NO;


            sv2.contentSize = CGSizeMake(ScreenWidth, ScreenHeight*(dynamicArr.count+1));

            [sv1 addSubview:imageView];

            

            

            [sv1 addSubview:sv2];

            [imageView release];

            

            [sv2 release];


            

            for (int k=0; k<dynamicArr.count; k++) {  //加在动态交互层

                

                UIImageView *imageV=[[UIImageView alloc] initWithFrame:CGRectMake(0,ScreenHeight*(k+1), ScreenWidth, ScreenHeight)];

                imageV.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:dynamicArr[k]  ofType:nil]];

                

                //                NSLog(@"%@",dynamicArr[k] );//有数据

                [sv2 addSubview:imageV];

                [imageV release];

                

                

            }

            

            

            

        }

        //横向的滚动试图 加到上面来

        [sv addSubview:sv1];

      

          [sv1 release];

    }

    

    //得出结论  凡是 循环 创建的  变量   不管 是 临时的  还是 全局的   都 应该再 相对应的循环 下面 去 释放  。  全局的 再delloc里面 去释放 相当于 只是 释放了 一次     所以  多点几次 就警告了    



所以 的记住 


你可能感兴趣的:(关于ios内存警告)