Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UITableView显示额外的空白空间_Objective C_Ios_Uitableview_Whitespace - Fatal编程技术网

Objective c UITableView显示额外的空白空间

Objective c UITableView显示额外的空白空间,objective-c,ios,uitableview,whitespace,Objective C,Ios,Uitableview,Whitespace,UITableView在插入解析数据数组后,在左侧显示额外的空白。所以,我的问题是如何在tableView中修剪空白。我想我有空白,因为HREF超链接到我解析的文本,它在单元格中显示为空白。< /P> 这是我解析的HTML的一部分: <h3 style="clear:left"><a class="c4" href="http://www.website.ge/article-22624.html"> Facebook - the text I hav

UITableView在插入解析数据数组后,在左侧显示额外的空白。所以,我的问题是如何在tableView中修剪空白。我想我有空白,因为HREF超链接到我解析的文本,它在单元格中显示为空白。< /P> 这是我解析的HTML的一部分:

 <h3 style="clear:left"><a class="c4" href="http://www.website.ge/article-22624.html">
         Facebook - the text I have parsed </a></h3>
在表视图中,我看到解析数据的开头有空格。它必须是翻译成空白的超链接

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellIdentifier = @"Cell";
    //here you check for PreCreated cell.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    //Fill the cells...  
    cell.textLabel.textAlignment=UITextAlignmentLeft; // attempt to move it to the left

    cell.textLabel.text = [listData objectAtIndex: indexPath.row];
    //yourMutableArray is Array 
    return cell;
}

根据您的描述,我假设您在标签中显示的文本中有额外的空白

如果是这种情况,请使用已创建的字符串,并在设置标签之前使用以下命令:

theStringToDisplay = [theStringToDisplay stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
theLabel.text      = theStringToDisplay;
提供代码后立即编辑:
在您的情况下,当您第一次在数组中设置字符串时,我会使用
stringByTrimmingCharactersInSet

NSArray *divNodes = [bodyNode findChildrenOfClass:@"c4"];
for (HTMLNode *inputNode in divNodes) {
    [listData addObject:[[inputNode contents] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
} 

如何将此方法应用于数组?它看起来像我需要的,但它说whitespaceCharacterSet是未声明的标识符。这是一个类方法,所以需要[NSCharacterSet whitespaceCharacterSet]什么不起作用?您是否仍然存在与开始时相同的问题,或者您是否遇到了错误?您的意思是这样做是正确的?[listData添加对象:[[inputNode内容]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSArray *divNodes = [bodyNode findChildrenOfClass:@"c4"];
for (HTMLNode *inputNode in divNodes) {
    [listData addObject:[[inputNode contents] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
}