2011-04-26 59 views
3

當我試圖在我的UITableview中顯示泰米爾字符時,我無法順利滾動tableview,但如果用英文字符替換泰米爾字符,則滾動時不會出現問題。使用泰米爾文字時UItableview滾動問題

任何解決方案?

在此先感謝!

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *CellIdentifier   = @"Cell"; 
UITableViewCell *cell     = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if(cell == nil) 
{ 
    cell       = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    cell.selectionStyle    = UITableViewCellSelectionStyleNone; 
    cell.backgroundColor=[UIColor yellowColor]; 

    UILabel *lblTitle = [[UILabel alloc]init]; 
    [lblTitle setTag:100]; 
    [lblTitle setBackgroundColor:[UIColor clearColor]]; 
    [lblTitle setFont:[UIFont fontWithName:@"Helvetica" size:13]]; 
    [lblTitle setFont:[UIFont boldSystemFontOfSize:14]]; 
    [lblTitle setTextColor:[UIColor blackColor]]; 
    [cell.contentView addSubview:lblTitle]; 
    [lblTitle release]; 

} 

UILabel  *plblTitle  = (UILabel*) [cell.contentView viewWithTag:100]; 

News *pNewsObj = [appDelegate.CurrentNewsArray objectAtIndex:indexPath.row]; 

plblTitle.text = pNewsObj.pHeadLine; 


return cell;   

}

+0

你用什麼來顯示泰米爾字符? – saadnib 2011-04-26 10:35:49

+0

我簡單地解析XML文本並在UItableview中顯示UIlabel – wan 2011-04-26 10:37:37

+0

您可以發佈cellForRowAtIndexPath代碼 – saadnib 2011-04-26 10:40:35

回答

2

您可以通過滾動視圖,標籤和按鈕創建自定義表視圖。

它的滾動非常順暢。

對於防爆。

In myView.h 

     IBOutlet UIScrollView *scrollView; 
     UIButton    *cell[2048]; 
     NSInteger    cellCount; 

- (void) createCell; 
- (void) removeCell; 


In myView.m 

- (void) createCell 
{ 
    [self removeCell]; 

    float x = 10.0; 
    float y = 5.0; 

    for (int i = 0; i < [Your NSMutableArray count]; i++) 
    { 
     cell[cellCount] = [UIButton buttonWithType:UIButtonTypeCustom]; 
     cell[cellCount].frame = CGRectMake(x, y, 176.0, 10.0); 
     [cell[cellCount] setTitle:@"Text" forState:UIControlStateNormal]; 
     [cell[cellCount] setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 
     cell[cellCount].titleLabel.font = [UIFont fontWithName:@"Arial" size:14.0]; 
     [cell[cellCount] addTarget:self action:@selector(cellEvent:) forControlEvents:UIControlEventTouchUpInside]; 
     cell[cellCount].tag = i; 

     [scrollView cell[cellCount]]; 

     cellCount++; 
     y = y + 15.0; 
    } 

    scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, y); 
} 

- (void) removeCell 
{ 
    for (int i = 0; i < cellCount; i++) 
    { 
     [cell[i] removeFromSuperview]; 
    } 
    cellCount = 0; 
} 
+0

感謝Chetan。我在該單元格中有三個標籤一個按鈕。所以我更願意堅持用UItableview。 – wan 2011-04-26 10:56:37