2011-11-08 5 views
0

XCODE 4.2로 업그레이드되었으며 갑자기 이러한 경고 신호가 나타납니다. 대부분 나는 고칠 수 있지만 다음은 어떻게해야할지 모르겠다. 나는 그것을 읽기 위해 노력했지만 여전히 문제가있다. 사용되지 않습니다해결 방법 : initWithFrame : CellFrame reuseIdentifier : cellIdentifier 권장되지 않음

코드는 다음과 같습니다

UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease]; 

나는 내가 다음 사용할 필요가 있음을 알고 난 테스트 할 때

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 

그러나, 난 등 CellFrame으로 문제를 얻는다.

누군가 내가 depWired 코드를 initWithStyle로 대체하고 동일한 결과를 얻는 방법에 대한 힌트를 줄 수 있습니까?

여기에 전체 코드입니다 :

- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier { 

CGRect CellFrame = CGRectMake(0, 0, 300, 60); 
CGRect Label1Frame = CGRectMake(10, 10, 290, 25); 
CGRect Label2Frame = CGRectMake(30, 33, 270, 25); 
CGRect Label3Frame = CGRectMake(30, 56, 270, 25); 
UILabel *lblTemp; 

UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease]; 

//Initialize Label with tag 1. 
lblTemp = [[UILabel alloc] initWithFrame:Label1Frame]; 
lblTemp.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.3f alpha:1.0f]; 
lblTemp.textColor = [UIColor whiteColor]; 
lblTemp.backgroundColor = [UIColor clearColor]; 
[lblTemp setFont:[UIFont fontWithName:@"American Typewriter" size:16]]; 
lblTemp.tag = 1; 
[cell.contentView addSubview:lblTemp]; 
[lblTemp release]; 

//Initialize Label with tag 2. 
lblTemp = [[UILabel alloc] initWithFrame:Label2Frame]; 
lblTemp.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.3f alpha:1.0f]; 
lblTemp.tag = 2; 
[lblTemp setFont:[UIFont fontWithName:@"American Typewriter" size:13]]; 
lblTemp.textColor = [UIColor whiteColor]; 
lblTemp.backgroundColor = [UIColor clearColor]; 
[cell.contentView addSubview:lblTemp]; 
[lblTemp release]; 

//Initialize Label with tag 3. 
lblTemp = [[UILabel alloc] initWithFrame:Label3Frame]; 
lblTemp.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.3f alpha:1.0f]; 
lblTemp.tag = 3; 
[lblTemp setFont:[UIFont fontWithName:@"American Typewriter" size:13]]; 
lblTemp.textColor = [UIColor whiteColor]; 
lblTemp.backgroundColor = [UIColor clearColor]; 
[cell.contentView addSubview:lblTemp]; 
[lblTemp release]; 

return cell; 
} 
+0

우리에게 당신이 initWithStyle를 사용하여 시도 코드를 보여이 코드를 사용하고, 우리에게 당신이있어 오류를 보여줍니다. –

답변

6

그냥 처음에 스타일을 초기화하고 설정 reuired 프레임 후. 내가 어떤 문제를 볼 수 없습니다 : 그 라인을 따라

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
     cell.frame = CellFrame; 
    } 
+0

내가 얻는 : 클래스 메서드 '+ dequeueReusableCellWithIdentifier :'찾을 수 없습니다 (반환 형식 기본값은 'ID') – PeterK

+0

'dequeueReusableCellWithIdentifier'는 UITableView 메서드입니다. – beryllium

+0

위의 코드에서이 문제를 해결하는 방법을 알려주십시오. – PeterK

1

뭔가

cell = [[[UITableViewCell alloc] initWithStyle:somestyle reuseIdentifier:@"cellname"] autorelease] 
cell.frame = cellFrame; 

스피 확실하지 당신이 정말로 당신이 어떤 특정 프레임을 원하지 않는다면 셀 프레임을 설정해야하는 경우, 그것은으로 설정해야합니다 tableview가 무엇이든간에.

0

난 그냥 cell = [[customCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

0
static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
{ 
     cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
} 
return cell; 
}