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 4109292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:46:39+00:00 2026-05-20T21:46:39+00:00

I a UITableView setup and loaded with about 3 records. The height of the

  • 0

I a UITableView setup and loaded with about 3 records. The height of the UITableView in Interface Builder is only 44 pixels. The height of each row is set to 44 pixels.

This means that only really one row is visible at a time but it is possible to drag and scroll to a new row. I want the UITableView too always show the most visible row scrolled to.

I have setup the following code:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    // Get the center of the UITableView bounds     
    CGPoint tableViewCenter = self.activeTableView.center;
    // Get the row that is currently occupying the center point in the UITableView  
    NSIndexPath *row = [self.activeTableView indexPathForRowAtPoint:CGPointMake(tableViewCenter.x, tableViewCenter.y)];
    // Animate and scroll to this row making it the only visible row.   
    [self.activeTableView scrollToRowAtIndexPath:row atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

My problem is that no matter what I do, it ALWAYS scrolls back to the 1st row record. I can drag all the way down to the 3rd row and let go, and it scrolls all the way back up to the 1st record? Shouldn’t it scroll and center the 3rd row if it’s the most visible row after I let go?

Thanks!

  • 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-05-20T21:46:40+00:00Added an answer on May 20, 2026 at 9:46 pm

    Your problem is that tableView.center doesn’t change when you scroll. Center only changes if you change the frame of the tableview.

    what you should use is the contentOffset of the UIScrollView.

    replace your tableViewCenter code with this and it should work

    CGPoint tableViewCenter = scrollView.contentOffset;
    // contentOffset is the position of the first visible pixel in the upper left corner 
    // add half the height so the relevant point is in the middle of the tableView
    tableViewCenter.y += self. activeTableView.frame.size.height/2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableview setup in my iphone app. At the moment, each row
I have a UITableView . In row I need to setup text, so I
i know it will be setup cell on this method - (UITableViewCell *)tableView:(UITableView *)tableView
I have an UITableView set up with a NSArray with 10 indexes. Right now,
I have set up a UITableView-based app, which has a .plist for holding the
I am using a static UITableview, set up in a storyboard. For some cells
UITableView only shows data from JSON array when I scroll up and down. When
In UITableView.h, in the interface declaration for UITableView, there is an ivar struct _tableFlags.
My UITableView has 3 sections. Only the cells in the 2nd sections are movable:
I have setup a UITableView (320 wide) with a UITableViewCell created in IB, the

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.