【问题标题】:UItableview scrolling problem when using tamil text使用泰米尔语文本时的 UItableview 滚动问题
【发布时间】:2011-08-12 22:37:35
【问题描述】:

当我尝试在UITableview 中显示泰米尔语字符时,我无法平滑滚动tableview,但如果我将泰米尔语字符替换为英文字符,则滚动没有问题。

有什么解决办法吗?

提前致谢!!!

- (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;        

}

【问题讨论】:

  • 你用什么来显示泰米尔语字符?
  • 我只是从 xml 中解析文本并将其显示在 UItableview 内的 UIlabel 中
  • 能贴出cellForRowAtIndexPath的代码

标签: iphone uitableview scroll uifont tamil


【解决方案1】:

您可以使用滚动视图、标签和按钮创建自定义表格视图。

而且它的滚动非常流畅。

例如

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;
}

【讨论】:

  • 感谢切坦。我在该单元格中有三个标签一个按钮。所以我更喜欢坚持使用 UItableview。
猜你喜欢
  • 2016-12-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多