2011-01-12 6 views
1

alt textalt text 정적 NSString * CellIdentifier = @ "셀";nsxmlparse 테이블 뷰 정렬

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@""]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
} 
cell.backgroundView = [[[CustomCell alloc] init] autorelease]; 
cell.selectedBackgroundView = [[[CustomCell alloc] init] autorelease]; 

// At end of function, right before return cell: 
cell.textLabel.backgroundColor = [UIColor clearColor]; 


// Configure the cell. 
UILabel *myLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 45)]; 
UILabel *myLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(5, 55, 300, 20)]; 
UILabel *myLabel3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 68, 300, 60)]; 

Book *aBook = [appDelegate.books objectAtIndex:indexPath.row]; 

    myLabel1.text=aBook.title; 
    myLabel2.text=aBook.pubDate; 
    myLabel3.text=aBook.description; 


//myLabel1.lineBreakMode=UILineBreakModeCharacterWrap; 
myLabel1.lineBreakMode=UILineBreakModeWordWrap; 
myLabel1.numberOfLines=1; 
myLabel1.textColor=[UIColor redColor]; 
myLabel1.backgroundColor = [UIColor blueColor]; 
myLabel1.font=[UIFont systemFontOfSize:14]; 

myLabel2.font=[UIFont systemFontOfSize:12]; 

myLabel3.textAlignment=UITextAlignmentLeft; 
myLabel3.textColor=[UIColor blueColor]; 
myLabel3.lineBreakMode=UILineBreakModeCharacterWrap; 
myLabel3.numberOfLines=3; 
//myLabel3.lineBreakMode=UILineBreakModeWordWrap; 
myLabel3.lineBreakMode=UILineBreakModeTailTruncation; 
myLabel3.font=[UIFont systemFontOfSize:14]; 



//myLabel1.shadowColor=[UIColor redColor]; 
//myLabel1.backgroundColor=[UIColor grayColor]; 
     [cell.contentView addSubview:myLabel1]; 
     [cell.contentView addSubview:myLabel2]; 
     [cell.contentView addSubview:myLabel3]; 




    //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
[myLabel1 release]; 
[myLabel2 release]; 
[myLabel3 release]; 
//Set up the cell 

return cell; 

나는이 코딩을 가지고 있습니다. mylabel 1에서 2로 설정하면 텍스트가 내려 가서 볼 수 없습니다. 이제 마지막으로 제목 2 줄, pubDate 1 줄 및 설명 3 줄을 한 줄에 표시하고 싶습니다. 내가 표시 한하지만, 그것은 HTML (& mdash) 태그를 제거 할 몇 가지 정렬을 위의 점 익스플로러 필요

내가

+0

처럼 보이는 것이다 사용자 정의 셀 클래스와 있는 UITableViewCell
을 하위 클래스입니까? –

+0

ddd에오다 – Splendid

답변

1

서브 클래스있는 UITableViewCell 나 좀 도와 this.pls와 this.struggling 사용자 정의에 얼굴을 잘 모릅니다과 해당 사용자 정의 셀을 사용하십시오.

여기서 첫 번째 문제는 셀이 표시 될 때마다 레이블을 추가한다는 것입니다. 그러나 모든 준비가 된 일부 셀을 컨텐츠에 재사용 할 수 있으므로 레이블을 다시 볼 수 있습니다.

두 번째 문제점은 init을 할당 할 때마다 성능이며 각 행에 릴리스 3 레이블이 표시됩니다. 이렇게하면 iPhone 3G와 같은 느린 장치에서 느린 스크롤 속도가 발생합니다.

Apple의 CustomTableViewCell sample code을 살펴보십시오.

Here

당신이 화면을 캡처하고 무슨 일이 일어나고 있는지 우리에게 보여 할 수있는 튜토리얼 방법 방법이

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 
    CustomTableViewCell *cell = (CustomTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 
    [cell setLabel1String:aBook.title]; 
    [cell setLabel2String:aBook.pubDate]; 
    [cell setLabel3String:aBook.description]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

    return cell; 
} 
+0

어이 can not는 u를 얻는다. pls 날 클리어 – Splendid

+0

이 코드를 편집하고 내게 – Splendid

+0

줄 당신의 코드에 잘못 가고 있습니다. 내 게시물 –