1

I am new to iOS and i have some serious problem i don't know why this happened, i also tried to find out the reason behind this but i failed.

I am creating a app in iPhone which take tweet of particular user using twitter api, i have no problem in getting the json data, also able to display it in UITableView in iOS 6 using storyboard, i had changed the row height to 200 px, so that i can display user name text tweet and image.

But when I scroll up or down the UITableViewCell the scrollbar goes out of the screen.

What may be the reason?how can I fix it?

ScreenShots

First it shows like this when the app loads the scrollbar takes the full screen

enter image description here


then when i scroll it get out of the screen

enter image description here

at last it completely gets out of screen

enter image description here

UITableView delegate methods

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSMutableArray *name,*time,*tweet,*image;

    name=[[NSMutableArray alloc]init];
    time=[[NSMutableArray alloc]init];
    tweet=[[NSMutableArray alloc]init];
    image=[[NSMutableArray alloc]init];


    static NSString *CellIdentifier = @"SimpleTableItem";

    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];


    for (User *userModel in self.user) {
        [name addObject:userModel.nameStr];
        [image addObject:userModel.imageStr];

    }

    for (Json *jsonModel in self.json) {
        [tweet addObject:jsonModel.tweetStr];
        [time addObject:jsonModel.timeStr];


    }

    // Fetch using GCD
    dispatch_queue_t downloadThumbnailQueue = dispatch_queue_create("Get Photo Thumbnail", NULL);
    dispatch_async(downloadThumbnailQueue, ^{
        NSString *imageURL=[image objectAtIndex:indexPath.row];
        NSURL *url = [NSURL URLWithString:imageURL];
        NSData *data = [NSData dataWithContentsOfURL:url];
        UIImage *img = [[UIImage alloc] initWithData:data];
        dispatch_async(dispatch_get_main_queue(), ^{

            UIImageView *image = (UIImageView *)[cell.contentView viewWithTag:5];
            image.image=img;

            [cell setNeedsLayout];
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
            [spinner stopAnimating];

        });
    });

    self.labelName = (UILabel *)[cell.contentView viewWithTag:10];
    [self.labelName setText:[NSString stringWithFormat:@"%@", [name objectAtIndex:indexPath.row]]];


   self.labelTime = (UILabel *)[cell.contentView viewWithTag:11];
    [self.labelTime setText:[NSString stringWithFormat:@"%@", [time objectAtIndex:indexPath.row]]];




     self.labelTweet = (UILabel *)[cell.contentView viewWithTag:12];
    [self.labelTweet setText:[NSString stringWithFormat:@"%@", [tweet objectAtIndex:indexPath.row]]];


    cell.imageView.frame=CGRectMake(0, 0, 40, 40);
    cell.textLabel.lineBreakMode=NSLineBreakByWordWrapping;

    return cell;

}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat rowHeight=self.labelName.frame.size.height+self.labelTime.frame.size.height+self.labelTweet.frame.size.height+50;
        return rowHeight;
}
10
  • 1
    Can you post the screen shot????
    – Venk
    Commented May 22, 2013 at 5:05
  • can you post some code my friend?
    – NiravPatel
    Commented May 22, 2013 at 5:05
  • cant understand what you mean by scrollbar goes out of the screen Commented May 22, 2013 at 5:09
  • Can you shw your code and some screen shot
    – iEinstein
    Commented May 22, 2013 at 5:10
  • how to take a screen shot
    – Arun
    Commented May 22, 2013 at 5:12

3 Answers 3

2

Well scroll goes out of the screen means the tableView frame is larger than the screen size

Set the frame of tableview properly using setFrame: method

0
1

I think you have to check the height of the UITableView. Show the screenshot.

0
0

Here the ScrollBar goes down as the Height of TableView is larger then the UIView in which you are adding TableView. Adjust the frame according to your view then the ScrollBar will not disappear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.