0

測量アプリを作ろうとしていますが、ARCを使っているのにメモリ管理ができません。アプリでメモリ リークが発生します。メモリの警告が表示されます。インターフェイスビルダーでアプリを静的に作成しても問題はありませんが、プログラムでアプリを作成するとメモリの問題が発生します。なぜそれが起こっているのですか?これが私のコードです:

#import "ViewController.h"
#import <QuartzCore/QuartzCore.h>
int soruAdedi = 20;
@interface ViewController ()

@end

@implementation ViewController
@synthesize scrollView2;
-(void)textViewBicimle: (UITextField *)textAlani{
    [textAlani.layer setBorderColor:[[[UIColor blackColor] colorWithAlphaComponent:1.0] CGColor]];
    [textAlani.layer setBorderWidth:1.0];
}

- (void) tableCiz:(NSMutableArray *)hucreler sutun:(int)sutunSayisi satir:(int)satirSayisi{
    int z = 0;
    for (int i =0;i<satirSayisi;i++){
        for(int j=0;j<sutunSayisi&&z<satirSayisi*sutunSayisi;j++,z++){
            [self textViewBicimle:[hucreler objectAtIndex:z]];
            [[hucreler objectAtIndex:z] setFrame:CGRectMake((20+j*100), (20+i*40), 100, 40)];
        }
    }
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

}

-(void)hucreArrayOlustur: (int)sutunSayisi suankiView:(UIView *)soruViewIki satir:(int)satirSayisi{
    for (int i = 0; i <sutunSayisi*satirSayisi; i++){
        textView = [[UITextField alloc]init];
        textView.text = @"dsgfdh";
        [hucreArray addObject:textView];
        [soruViewIki addSubview:textView];
    }
}

-(void)viewOlustur{
    for (int i = 0; i <soruAdedi; i++){
        hucreArray = [[NSMutableArray alloc]init];
        if (i == 0){
            soruView = [[UIView alloc]initWithFrame:CGRectMake(20, 20, 728, 0)];
            soruView.clipsToBounds = YES;
            soruView.backgroundColor = [UIColor lightGrayColor];
            [self hucreArrayOlustur:5 suankiView:soruView satir:10];
            [self tableCiz:hucreArray sutun:5 satir:10];
            CGRect frame = soruView.frame;
            CGRect frame2 = [[hucreArray objectAtIndex:49] frame];
            frame.size.height =  frame2.origin.y+frame2.size.height+34;
            soruView.frame = frame;
            [viewArray addObject:soruView];
            [scrollView2 addSubview:soruView];
        }
        else{
            CGRect frameGecici = [[viewArray objectAtIndex:i-1] frame];
            float geciciY = frameGecici.origin.y+frameGecici.size.height+1;
            soruView = [[UIView alloc]initWithFrame:CGRectMake(20, geciciY, 728, 0)];
            soruView.clipsToBounds = YES;
            soruView.backgroundColor = [UIColor lightGrayColor];
            [self hucreArrayOlustur:5 suankiView:soruView satir:10];
            [self tableCiz:hucreArray sutun:5 satir:10];
            CGRect frame = soruView.frame;
            CGRect frame2 = [[hucreArray objectAtIndex:49] frame];
            frame.size.height =  frame2.origin.y+frame2.size.height+34;
            soruView.frame = frame;
            [viewArray addObject:soruView];
            [scrollView2 addSubview:soruView];
        }
    }
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    scrollView2.delegate = self;
    scrollView2.contentSize = CGSizeMake(0, 8000);
    viewArray = [[NSMutableArray alloc]init];
    [self viewOlustur];
    // Do any additional setup after loading the view, typically from a nib.
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidUnload {
    [self setScrollView2:nil];
    [super viewDidUnload];
}
@end
4

0 に答える 0