lMenu_time (UILabel)의 텍스트를 처음 설정 한 후에 변경할 수 없습니다. 콜백이 실행되고 테스트했지만 텍스트는 변경되지 않습니다. ?? 포인터 주위를 지나가고 UILabel을 조정합니다. ??UILabel 텍스트가 변경되지 않습니까?
lMenu_time과 그 외 다수가 헤더 파일에 정의되어 있습니다. 콘솔 출력은 "내 레이블 인 경우 다음을 설정하려고 직전에
UILabel *lMenu_time;
...
-(void) NewNumber: (UIButton*) btn {
if (btn.tag == 102){
iTime++;
[lbl setText:@"time"];
if(iTime > 20){iTime=1;}
[lMenu_time setText:[NSString stringWithFormat: @"Hold: %d", iTime]];
}
....
}
- (void) menuItem: (UIView*)vMenu menuButton:(UIButton*)bMenu menuLabel: (UILabel*)lMenu menuPosX: (double)posX menuLenX: (double)lenX menuTagNum: (int)tagNum menuText: (NSString*)txtMenu{
bMenu = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[bMenu setFrame:CGRectMake(posX,0,lenX,25)];
[bMenu setTag: tagNum];
[bMenu addTarget:self action:@selector(NewNumber:) forControlEvents:UIControlEventTouchUpInside];
[vMenu addSubview:bMenu];
lMenu = [[[UILabel alloc] initWithFrame:CGRectMake(posX,0,lenX,25)] retain];
[lMenu setBackgroundColor:[UIColor lightGrayColor]];
[lMenu setText:[NSString stringWithFormat: txtMenu]];
[lMenu setFont:[UIFont systemFontOfSize:14 ]];
[lMenu setTextAlignment:UITextAlignmentCenter];
[vMenu addSubview: lMenu];
}
- (void) menuBuild{
pSelf = self;
theString = @"";
UIView *vMenu = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,25)];
[pSelf.view addSubview:vMenu];
[vMenu setBackgroundColor:[UIColor grayColor]];
iTime = 2;
[self menuItem:vMenu menuButton:bMenu_time menuLabel:lMenu_time menuPosX:240+20 menuLenX:60 menuTagNum:102 menuText:[NSString stringWithFormat: @"Hold: %d", iTime]];
...
}
나는 그것이 0이라는 것을 깨닫는다. 왜 이것이 null인지 확실하지 않습니다. 왜 그것이 ... 나는 UILabel "alloc"을 했음에도 불구하고 "retain"을해야합니까? – jdl
lMenu_time은 뷰 컨트롤러의'@ 속성 '입니까? – Tim
코드에서 해당 레이블이 생성되었음을 알 수 있습니다. – jdl