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

  • Home
  • SEARCH
  • 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 9122319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:04:29+00:00 2026-06-17T06:04:29+00:00

I have the code below to display popover with tableview and it works perfectly.

  • 0

I have the code below to display popover with tableview and it works perfectly.

The tableview displays 13 numbers and I can scroll and see the same but when I release mouse-touch on simulator it goes back to the top.

It does not stay at the row which its displaying but takes me back to 1st to 10th row .

How do I make it stay in the position after scrolling. Or any fix in the below code.

Thanks in Advance.

- (IBAction)btn:(id)sender {

    if([popoverController isPopoverVisible])
    {
        [popoverController dismissPopoverAnimated:YES];
        return;
    }
    //build our custom popover view
    UIViewController* popoverContent = [[UIViewController alloc]init];
    UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 680)];
    popoverView.backgroundColor = [UIColor blackColor];

    numbers = [[NSMutableArray alloc] initWithObjects:@"1",@"2", @"3",@"4",@"5", @"6",@"7", @"8", @"9",@"10",@"11", @"12",@"13",nil];


    UITableView *tblViewMenu = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 680)];
    tblViewMenu.delegate = self;
    tblViewMenu.dataSource = self;
    tblViewMenu.rowHeight = 32;

    [popoverView addSubview:tblViewMenu];
    popoverContent.view = popoverView;
    popoverContent.contentSizeForViewInPopover = CGSizeMake(320, 320);
    popoverController = [[UIPopoverController alloc]
                              initWithContentViewController:popoverContent];

    [popoverController  presentPopoverFromRect:self.btn.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}




- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [numbers count];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

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

    // Configure the cell...
    NSString *color = [numbers objectAtIndex:indexPath.row];
    cell.textLabel.text = color;

    return cell;
}

#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        NSString *number = [numbers objectAtIndex:indexPath.row];

    NSLog(@"%@",number);

    [popoverController dismissPopoverAnimated:YES];

    }

I Guess I need to change the values below:

UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 680)];


    UITableView *tblViewMenu = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320,680)]];

If I use

UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];     

Then

  UITableView *tblViewMenu = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320,320)]];

But when I scroll down it keeps coming to the top row .It does not stay in the same row which is being scrolled to .

  • 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-17T06:04:30+00:00Added an answer on June 17, 2026 at 6:04 am

    Use autoresizing correctly!

    Popover – has content size

    popoverView – its initial size should be the same as popover’s content size and use
    UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight

    tblViewMenu– its initial size should be the same as the size of its ancestor (popoverView), again, use UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight

    Your table is not scrolling because it is so big that it doesn’t needs scrolling. Only the popover is clipping it.

    CGSize contentSize = CGSizeMake(320, 320);
    
    UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, contentSize.width, contentSize.height)];
    popoverView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    
    UITableView *tblViewMenu = [[UITableView alloc]initWithFrame:popoverView.bounds];
    tblViewMenu.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    
    popoverContent.contentSizeForViewInPopover = contentSize;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried using the code below but it only display results in Chrome
I have tried using the code below to display ImageIcons in JTable. But when
I'm a EE newbie. I have the code below. the poll weblog displays at
I have code that looks more or less like the code below but it
I have the code below and it works pretty good except if you enter
I have this code. The code below is working in Firefox, but it is
I have the code below but I cannot call nextPromo because it is not
i have the code below <div id=topbar> <a class=nav href=# onClick=if($('#embedding').css('display') == 'none') {
I have swf file, im using code below to display it on my website:
I have the code below, if i don't use watermark it's fine but when

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.