은 내가 UIPickerView의 행을 사용자 정의, 그래서 다음과 같이 나는 그것의 위임에 viewForRow 방법을 구현 해요 :코코아 터치 : 메모리 관리
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
if (view) {
return view;
} else {
NSString *s = [datePickerValues objectAtIndex:row];
UILabel *l = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
l.text = s;
l.font = [UIFont boldSystemFontOfSize:18];
l.textAlignment = UITextAlignmentCenter;
l.backgroundColor = [UIColor purpleColor];
[l autorelease];
return l;
}
}
내가의 Obj-C에 새로운 해요.
저는 aloc/initing이므로 메모리 관리 가이드에 따라 릴리스해야합니다. 그러나 나는 또한 그것을 돌려 줄 필요가있다. 자동 복구가 정상입니까?
당신의 코드에서 줄을 깎을 수 있습니다 return [l autorelease]; – pxl
alloc/init의 일부로 autorelease를 사용하거나 누그십시오. – Lounges