关于ios内存警告

来源:互联网 发布:淘宝充话费系统 编辑:程序博客网 时间:2024/06/05 03:19

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

        //创建纵向的scorllow

        

        

        

        

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

       sv1.bounces =YES;

       sv1.pagingEnabled =YES;

       sv1.tag = 100+i;

        sv1.showsVerticalScrollIndicator=NO;

        

        

        

       NSArray *blockArray=[pageDicobjectForKey:pageArr[i]];

        

        

        

      

        

        

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

            //设置纵向ScrollView的高度

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

            

           //设置静态层图片

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

            imageView.contentMode=UIViewContentModeScaleAspectFill;

            imageView.userInteractionEnabled =YES;

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

           imageView.image = [UIImageimageWithContentsOfFile:imageName];

            

            

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

            

            //纵向动态ScrollView

            sv2= [[UIScrollViewalloc] 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));

            [sv1addSubview:imageView];

            

            

            [sv1addSubview:sv2];

            [imageViewrelease];

            

            [sv2release];


            

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

                

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

                imageV.image = [UIImageimageWithContentsOfFile:[[NSBundlemainBundle] pathForResource:dynamicArr[k] ofType:nil]];

                

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

                [sv2addSubview:imageV];

                [imageVrelease];

                

                

            }

            

            

            

        }

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

        [svaddSubview:sv1];

      

          [sv1release];

    }

    

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



所以 的记住 


原创粉丝点击