Xcode 如何在tableview中生成字幕文本

Xcode 如何在tableview中生成字幕文本,xcode,tableview,void,tableviewcell,Xcode,Tableview,Void,Tableviewcell,我想在tableViewCell中创建字幕文本。所以我找到了一些代码: - (void)fireTimer { NSMutableString *mutableText = [NSMutableString stringWithString: textLabel.text]; //Takes the first character and saves it into a string NSString *firstCharText = [mutableText substringWi

我想在tableViewCell中创建字幕文本。所以我找到了一些代码:

- (void)fireTimer
{
  NSMutableString *mutableText = [NSMutableString stringWithString: textLabel.text];
  //Takes the first character and saves it into a string
  NSString *firstCharText = [mutableText substringWithRange: NSMakeRange(0, 1)];
  //Removes the first character
  [mutableText deleteCharactersInRange: NSMakeRange(0, 1)];
  //Adds the first character string to the initial string
  [mutableText appendString: firstCharText];

  textLabel.text = mutableText;
}

但当我将此代码粘贴到我的项目时,我发现了一个错误,textLabel未找到。但是文本标签是我在手机里的文本。所以我要做的是在这段代码中从tableViewCell中查找TextLabel。也许您知道tableViewCell文本或详细信息文本中的字幕代码。谢谢

您可以从此链接下载AutoScrollLabel文件

然后将这些文件添加到项目中

在自定义单元格类中导入此类,
#导入“autoscrollabel.h”

并连接
yourcustocell.xib
文件中的标签插座

在viewController cellForRowIndexPath方法中

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell";

    YourCustomCell *cell= (answerCustomCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if(cell == nil)
    {

        NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"YourCustomCell" owner:self options:nil];

        for(id currrentObject in topLevelObjects)
        {
            if([currrentObject isKindOfClass:[UITableViewCell class]])
            {
                cell = (YourCustomCell*)currrentObject;
                break;
            }
        }
    }

cell.textLabel.text = @"Your text";
cell.detailLabel.text = @"Your text";

return cell;

}

请参阅此链接。希望它能工作。没有它的UILabel卷轴。但是我想在Celle中滚动这个标准文本,你是自定义单元格吗?或者像这样使用单元格。textLabel?如果您使用的是自定义单元格方式,则可以。其自定义单元格textLabel和详细信息文本均为自定义。
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell";

    YourCustomCell *cell= (answerCustomCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if(cell == nil)
    {

        NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"YourCustomCell" owner:self options:nil];

        for(id currrentObject in topLevelObjects)
        {
            if([currrentObject isKindOfClass:[UITableViewCell class]])
            {
                cell = (YourCustomCell*)currrentObject;
                break;
            }
        }
    }

cell.textLabel.text = @"Your text";
cell.detailLabel.text = @"Your text";

return cell;

}