Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone NSScrollView在滚动时出错-[CALayer isEqual:]:消息已发送到解除分配的实例”;_Iphone_Objective C_Uikit_Ios - Fatal编程技术网

Iphone NSScrollView在滚动时出错-[CALayer isEqual:]:消息已发送到解除分配的实例”;

Iphone NSScrollView在滚动时出错-[CALayer isEqual:]:消息已发送到解除分配的实例”;,iphone,objective-c,uikit,ios,Iphone,Objective C,Uikit,Ios,我正在尝试修复代码,但不知道为什么会出现以下错误: modifying layer that is being finalized - 0x11818240 2010-09-10 02:35:53.022 iPhone Monkey Curling[1606:207] modifying layer that is being finalized - 0x11818240 2010-09-10 02:35:53.023 iPhone Monkey Curling[1606:207] modify

我正在尝试修复代码,但不知道为什么会出现以下错误:

modifying layer that is being finalized - 0x11818240
2010-09-10 02:35:53.022 iPhone Monkey Curling[1606:207] modifying layer that is being finalized - 0x11818240
2010-09-10 02:35:53.023 iPhone Monkey Curling[1606:207] modifying layer that is being finalized - 0x11818240
2010-09-10 02:35:54.671 iPhone Monkey Curling[1606:207] *** -[CALayer isEqual:]: message sent to deallocated instance 0x11818240
当我的all_score_table scroll视图尝试滚动时(滚动尝试时立即崩溃),就会发生这种情况。以下是设置滚动视图的代码:

NSMutableArray * scores_data = [[first_data componentsSeparatedByString: @"\n"] mutableCopy];
        if ([scores_data count] != 3) {
            UIAlertView *connection_alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Malformed server response." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles: nil];
            [connection_alert show];
            [connection_alert release];
            return;
        }
        if([[scores_data objectAtIndex:0] isEqual:@""]){
            [scores_data replaceObjectAtIndex:0 withObject:@"No scores for today,"];
        }
        if([[scores_data objectAtIndex:1] isEqual:@""]){
            [scores_data replaceObjectAtIndex:1 withObject:@"No scores this week,"];
        }
        if([[scores_data objectAtIndex:2] isEqual:@""]){
            [scores_data replaceObjectAtIndex:2 withObject:@"No scores,"];
        }
        [scores_data replaceObjectAtIndex:0 withObject: [[scores_data objectAtIndex:0] componentsSeparatedByString: @";"]];
        [scores_data replaceObjectAtIndex:1 withObject: [[scores_data objectAtIndex:1] componentsSeparatedByString: @";"]];
        [scores_data replaceObjectAtIndex:2 withObject: [[scores_data objectAtIndex:2] componentsSeparatedByString: @";"]];
        NSLog(@"scores_data");
        if (todays_scores_table){
            //One of the tables exist so all of them must. Release them for renewal.
            [todays_scores_table release];
            [week_scores_table release];
            [all_scores_table release];
            [online_scores_pages release]; //release pages also
        }
        NSLog(@"1");
        todays_scores_table = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 110, 295, 300)];
        week_scores_table = [[UIScrollView alloc] initWithFrame:CGRectMake(330, 110, 295, 300)];
        all_scores_table = [[UIScrollView alloc] initWithFrame:CGRectMake(650, 110, 295, 300)];
        todays_scores_table.contentSize = CGSizeMake(205, 60 + 40*[[scores_data objectAtIndex:0] count]);
        week_scores_table.contentSize = CGSizeMake(205, 60 + 40*[[scores_data objectAtIndex:1] count]);
        all_scores_table.contentSize = CGSizeMake(205, 60 + 40*[[scores_data objectAtIndex:2] count]);
        NSLog(@"2");
        NSArray * score_data;
        NSString * path = [[NSBundle mainBundle] pathForResource: @"single_score_image" ofType:@"png"];
        NSData * data = [[NSData alloc] initWithContentsOfFile:path];
        UIImage * background_image = [[UIImage alloc] initWithData:data];
        UIImageView * background_view;
        UIImage * header_image;
        if(submission){
            path = [[NSBundle mainBundle] pathForResource: @"scores_header" ofType:@"png"];
            [data release];
            NSLog(@"3");
            data = [[NSData alloc] initWithContentsOfFile:path];
            header_image = [[UIImage alloc] initWithData:data];
        }
        UIImageView * header_view;
        int offset;
        UILabel * label;
        NSLog(@"4");
        UIScrollView * tables[3] = {todays_scores_table,week_scores_table,all_scores_table};
        online_scores_pages = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];
        online_scores_pages.contentSize = CGSizeMake(960, 420);
        online_scores_pages.pagingEnabled = YES; //Act like iphone home page
        UIImage * title_image;
        UIImageView * title_view;
        NSLog(@"5");
        //border for scores table
        [data release];
        path = [[NSBundle mainBundle] pathForResource: @"score_table_border" ofType:@"png"];
        data = [[NSData alloc] initWithContentsOfFile:path];
        UIImage * border_image = [[[UIImage alloc] initWithData:data] autorelease];
        UIImageView * score_table_border;
        for (int a = 0; a < 3; a++) {
            if(submission){ //Only do header when submitting score
                header_view = [[UIImageView alloc] initWithImage: header_image];
                header_view.frame = CGRectMake(10, 10, 275, 30);
                NSLog(@"5A");
                [tables[a] addSubview: header_view];
                [header_view release];
                label = [[UILabel alloc] initWithFrame:CGRectMake(25, 10, 245, 30)];
                label.backgroundColor = [UIColor clearColor];
                NSLog(@"5B");
                NSString * end;
                NSLog(@"5C");
                if ([[scores_data objectAtIndex:a+3] characterAtIndex:0] == '1'){
                    end = @"st";
                }else if ([[scores_data objectAtIndex:a+3] characterAtIndex:0] == '2'){
                    end = @"nd";
                }else if ([[scores_data objectAtIndex:a+3] characterAtIndex:0] == '3'){
                    end = @"rd";
                }else{
                    end = @"th";
                }
                NSArray * pos_data = [[scores_data objectAtIndex:a+3] componentsSeparatedByString: @"/"];
                label.text = [NSString stringWithFormat: @"You came %@%@ from %@ scores.",[pos_data objectAtIndex:0],end,[pos_data objectAtIndex:1]];
                [tables[a] addSubview:label];
                NSLog(@"5E");
                [label release];
                NSLog(@"6");
            }
            for (int x = 0; x < [[scores_data objectAtIndex:a] count]; x++){
                score_data = [[[scores_data objectAtIndex:a] objectAtIndex:x] componentsSeparatedByString: @","];
                //Image for each score
                offset = 50 + 40*x;
                background_view = [[UIImageView alloc] initWithImage: background_image];
                background_view.frame = CGRectMake(10, offset, 275, 30); //Reposition
                [tables[a] addSubview: background_view];
                [background_view release];
                //Add score position
                label = [[UILabel alloc] initWithFrame:CGRectMake(10, offset, 30, 30)];
                label.backgroundColor = [UIColor clearColor];
                label.text = [NSString stringWithFormat: @"%i",x+1];
                label.textAlignment = UITextAlignmentCenter;
                [tables[a] addSubview:label];
                [label release];
                NSLog(@"7 %@ \n\n %@",score_data,scores_data);
                //Add name
                label = [[UILabel alloc] initWithFrame:CGRectMake(55, offset, 190, 30)];
                label.backgroundColor = [UIColor clearColor];
                label.text = [score_data objectAtIndex:0];
                [tables[a] addSubview:label];
                [label release];
                //Add score
                label = [[UILabel alloc] initWithFrame:CGRectMake(55, offset, 225, 30)];
                label.backgroundColor = [UIColor clearColor];
                label.text = [NSString stringWithFormat: @"%@",[score_data objectAtIndex:1]];
                label.textAlignment = UITextAlignmentRight;
                [tables[a] addSubview:label];
                [label release];
                NSLog(@"8");
            }
            //Add title
            switch (a) {
                case 0:
                    path = [[NSBundle mainBundle] pathForResource: @"todays_scores_title" ofType:@"png"];
                    break;
                case 1:
                    path = [[NSBundle mainBundle] pathForResource: @"week_scores_title" ofType:@"png"];
                    break;
                case 2:
                    path = [[NSBundle mainBundle] pathForResource: @"all_scores_title" ofType:@"png"];
                    break;
            }
            [data release];
            data = [[NSData alloc] initWithContentsOfFile:path];
            title_image = [[[UIImage alloc] initWithData:data] autorelease];
            title_view = [[[UIImageView alloc] initWithImage: title_image] autorelease];
            title_view.frame = CGRectMake(25 + 320*a, 15, 270, 75); //Reposition and resize
            [online_scores_pages addSubview:title_view];
            NSLog(@"9");
            //Add table
            score_table_border = [[UIImageView alloc] initWithImage: border_image];
            score_table_border.frame = CGRectMake(320*a, 100, 320, 320); //Reposition
            [online_scores_pages addSubview: tables[a]];
            [online_scores_pages addSubview: score_table_border];
            [score_table_border release];
        }
        [data release];
        if(submission){
            [header_image release];
            [header_view release];
        }
        [background_image release];
        [background_view release];
        [self addSubview: online_scores_pages];
        [online_scores_pages becomeFirstResponder];
NSMutableArray*得分\u数据=[[第一个\u数据组件由字符串分隔:@“\n”]mutableCopy];
如果([分数\数据计数]!=3){
UIAlertView*connection_alert=[[UIAlertView alloc]initWithTitle:@“错误”消息:@“格式错误的服务器响应”。委托:nil cancelButtonTitle:@“关闭”其他ButtonTitles:nil];
[连接警报显示];
[连接警报释放];
返回;
}
如果([[scores_data objectAtIndex:0]isEqual:@”“])){
[scores_data replaceObjectAtIndex:0 with Object:@“今天没有分数,”;
}
如果([[scores_data objectAtIndex:1]isEqual:@”“])){
[scores_data replaceObjectAtIndex:1 with Object:@“本周无分数,”;
}
如果([[scores_data objectAtIndex:2]isEqual:@”“])){
[分数\数据替换对象索引:2,对象:@“无分数,”;
}
[scores_data replaceObjectAtIndex:0与对象:[[scores_data objectAtIndex:0]组件由字符串@分隔“];
[scores_data replaceObjectAtIndex:1与对象:[[scores_data objectAtIndex:1]组件由字符串@分隔“];
[scores_data replaceObjectAtIndex:2与对象:[[scores_data objectAtIndex:2]组件由字符串@分隔“];
NSLog(“分数数据”);
如果(今天的分数表){
//其中一个表存在,因此所有表都必须存在。请释放它们以进行续订。
[今日分数表发布];
[周分数表发布];
[所有评分表发布];
[online_scores_pages release];//同时发布网页
}
NSLog(@“1”);
todays_scores_table=[[UIScrollView alloc]initWithFrame:CGRectMake(101110295300)];
周评分表=[[UIScrollView alloc]initWithFrame:cRectMake(330、110、295、300)];
所有评分表=[[UIScrollView alloc]initWithFrame:cRectMake(650110295300)];
todays_scores_table.contentSize=CGSizeMake(205,60+40*[[scores_data objectAtIndex:0]计数]);
week_scores_table.contentSize=CGSizeMake(205,60+40*[[scores_data objectAtIndex:1]计数]);
所有分数\u table.contentSize=CGSizeMake(205,60+40*[[scores\u data objectAtIndex:2]计数]);
NSLog(@“2”);
NSArray*得分数据;
NSString*path=[[NSBundle mainBundle]pathForResource:@“png”类型的“single_score_image”;
NSData*data=[[NSData alloc]initWithContentsOfFile:path];
UIImage*background_image=[[UIImage alloc]initWithData:data];
UIImageView*背景视图;
UIImage*标题_图像;
如果(提交){
path=[[NSBundle mainBundle]pathForResource:@“png”类型的“分数头”;
[数据发布];
NSLog(@“3”);
数据=[[NSData alloc]initWithContentsOfFile:path];
header_image=[[UIImage alloc]initWithData:data];
}
UIImageView*标题视图;
整数偏移量;
UILabel*标签;
NSLog(@“4”);
UIScrollView*表[3]={今天的分数表、周分数表、所有分数表};
在线评分页面=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0320420)];
在线评分页面.contentSize=CGSizeMake(960420);
online_scores_pages.paginEnabled=是//就像iphone主页一样
UIImage*标题图片;
UIImageView*标题视图;
NSLog(@“5”);
//分数表边框
[数据发布];
path=[[NSBundle mainBundle]pathForResource:@“png”类型的“分数表边框”;
数据=[[NSData alloc]initWithContentsOfFile:path];
UIImage*border_image=[[UIImage alloc]initWithData:data]autorelease];
UIImageView*分数表边框;
对于(int a=0;a<3;a++){
如果(提交){//提交分数时只做标题
header_view=[[UIImageView alloc]initWithImage:header_image];
标题_view.frame=CGRectMake(10,10,275,30);
NSLog(@“5A”);
[表[a]添加子视图:标题视图];
[标题视图发布];
label=[[UILabel alloc]initWithFrame:CGRectMake(25,10245,30)];
label.backgroundColor=[UIColor clearColor];
NSLog(@“5B”);
NSString*结束;
NSLog(@“5C”);
如果([[scores\u data objectAtIndex:a+3]字符AtIndex:0]=='1'){
结束=@“st”;
}else if([[scores\u data objectAtIndex:a+3]characterAtIndex:0]=='2'){
结束=@“nd”;
}else if([[scores\u data objectAtIndex:a+3]characterAtIndex:0]=='3'){
结束=@“rd”;
}否则{
结束=@“th”;
}
NSArray*pos_data=[[scores_data objectAtIndex:a+3]组件由字符串@”/“]分隔;
label.text=[NSString stringWithFormat:@“您来自%@分数%@%.”,[pos_数据对象索引:0],结束[pos_数据对象索引:1];
[表[a]添加子视图:标签];
NSLog(@“5E”);
[标签发布];
NSLog(@“6”);
}
对于(int x=0;x<[[scores_data objectAtIndex:a]count];x++){
score_data=[[[scores_data objectAtIndex:a]objectAtIndex:x]由字符串@“,”分隔的组件;
//每个分数的图像
偏移量=50+40*x;
background_view=[[UIImageView alloc]initWithImage:background_image];
background_view.frame=CGRectMake(10,偏移量,275,
if([[scores_data objectAtIndex:0] isEqual:@""]){ 
if([[scores_data objectAtIndex:1] isEqual:@""]){ 
if([[scores_data objectAtIndex:2] isEqual:@""]){
MutableArray * scores_data = [[first_data componentsSeparatedByString: @"\n"] mutableCopy];