Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8025471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:10:30+00:00 2026-06-04T23:10:30+00:00

UITableView shows extra blank space on the left, after I inserted array of parsed

  • 0

UITableView shows extra blank space on the left, after I inserted array of parsed data. So, my question is how to trim whitespace in the tableView. I guess I have the blank space because of href hyperlink to the text I parsed which is shown as blank in the cell.

This is the part of HTML I parsed:

 <h3 style="clear:left"><a class="c4" href="http://www.website.ge/article-22624.html">
         Facebook - the text I have parsed </a></h3>

This is the code I used:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    NSError *error = nil;
    NSURL *url=[[NSURL alloc] initWithString:@"http://www.website.ge/news"];
    NSString *strin=[[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];

    HTMLParser *parser = [[HTMLParser alloc] initWithString:strin error:&error];

    if (error) {
        NSLog(@"Error: %@", error);
        return;
    }

    listData =[[NSMutableArray alloc] init];


    HTMLNode *bodyNode = [parser body];
    NSArray *dateNodes = [bodyNode findChildTags:@"span"];


    for (HTMLNode *inputNode in dateNodes) {
        if ([[inputNode getAttributeNamed:@"class"] isEqualToString:@"date"]) {
            //NSLog(@"%@", [inputNode contents]); 
            //[listData addObject:[inputNode contents]];
        }
    }    

    NSArray *divNodes = [bodyNode findChildrenOfClass:@"c4"];

    for (HTMLNode *inputNode in divNodes) {


           [listData addObject:[inputNode contents]];

            }

}

In the table view I see blank space at the beginning of the parsed data. It must be the hyperlink which is translated into blank space.

- (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;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:10:31+00:00Added an answer on June 4, 2026 at 11:10 pm

    I’m assuming, based on your description, that you have extra whitespace in the text which you are displaying in a label.

    If this is the case, take the string that you have created, and before setting the label use this:

    theStringToDisplay = [theStringToDisplay stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    theLabel.text      = theStringToDisplay;
    

    EDIT now that you have supplied your code:
    In your case, I would use stringByTrimmingCharactersInSet when you are first setting the strings in your array:

    NSArray *divNodes = [bodyNode findChildrenOfClass:@"c4"];
    for (HTMLNode *inputNode in divNodes) {
        [listData addObject:[[inputNode contents] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UITableView only shows data from JSON array when I scroll up and down. When
I have gone through this question that shows the following code: -(NSString *)tableView:(UITableView *)tableView
when i use this code it shows an error - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
I want to create a view that shows vast amounts of data. Using UITableView
I have a UIPopOverController that shows a UIViewController with a UITableview in its view.
Did actually someone make already a tutorial that shows how to customize an UITableView?
Currently I have a UITableview, I have enough data that cannot be shown entirely
I have a UITableView which shows some information. The informations are from a XMLFile.
I am looking for a tutorial that shows how to populate a UITableView from
My UITableView get data off the internet. Sometimes it doesn't receive any (cell) data.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.