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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:45:31+00:00 2026-05-23T22:45:31+00:00

I have a UISlider in a section header. Sliding the slider will change the

  • 0

I have a UISlider in a section header. Sliding the slider will change the current table cell, as a sort of “speed scroll” mechanism.

It works great, BUT when it hits the item in the middle of the screen (item #7), a hiccup occurs (I assume when it’s re-centering the selected list item) and causing the UISlider to reset to the minimum.

Here’s the relevant code in the View Controller:

//
//  ChapterSelectionView.m
//  TestApp
//
//  Created by Darren Ehlers on 6/2/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ChapterSelectionView.h"
#import "ContentView.h"

@implementation ChapterSelectionView

@synthesize initSection;
@synthesize initRow;
@synthesize Book;
@synthesize Chapter;

@synthesize backButton;
@synthesize contentView;
@synthesize chapterList;
@synthesize navBar;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) 
    {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [slider release];

    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn"t have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren"t in use.
}

- (void) updateLabel:(id)sender
{
    NSLog(@"slider.value=%f (%d)", slider.value, (int)(slider.value + 0.5));
    self.Chapter       = (int)(slider.value + 0.5);
    navBar.topItem.title    = [NSString stringWithFormat:@"%@ %d", self.Book.name, self.Chapter];

    [chapterList selectRowAtIndexPath:[NSIndexPath indexPathForRow:(self.Chapter - 1) inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];
}

-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.Book chapterCount];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{
    CGRect  headerFrame = CGRectMake(0, 0, 320, 30);

    UIView *headerView = [[[UIView alloc] initWithFrame:headerFrame] autorelease];

    UILabel *headerLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 30, headerView.frame.size.height)];
    UILabel *headerLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(headerView.frame.size.width - 30, 0, 30, headerView.frame.size.height)];

    CGRect  frame = CGRectMake(40, 0, 240, 30);

    slider = [[UISlider alloc] initWithFrame:frame];
    slider.minimumValue = 1.0;
    slider.maximumValue = [self.Book chapterCount];
    slider.continuous = YES;
    slider.value = self.Chapter;

    [slider addTarget:self
               action:@selector(updateLabel:)
     forControlEvents:UIControlEventValueChanged];

    [headerView addSubview: slider];

    headerView.backgroundColor    = [UIColor lightGrayColor];

    UIFont *helvetica   = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    headerLabel1.font   = helvetica;
    headerLabel1.text   = @"1";
    headerLabel1.textColor      = [UIColor blackColor];
    headerLabel1.textAlignment  = UITextAlignmentRight;

    headerLabel1.opaque          = TRUE;
    headerLabel1.backgroundColor = [UIColor lightGrayColor];

    [headerView addSubview:headerLabel1];
    [headerLabel1 release];

    headerLabel2.font   = helvetica;
    headerLabel2.text   = [NSString stringWithFormat:@"%d", [self.Book chapterCount]];
    headerLabel2.textColor      = [UIColor blackColor];
    headerLabel2.textAlignment  = UITextAlignmentLeft;

    headerLabel2.opaque          = TRUE;
    headerLabel2.backgroundColor = [UIColor lightGrayColor];

    [headerView addSubview:headerLabel2];
    [headerLabel2 release];

    return headerView;
}

-(float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{
    return 30.0;
}

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *myCellID   = @"MyCellIdentifier";

    UITableViewCell *cell   = [tableView dequeueReusableCellWithIdentifier:myCellID];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:myCellID] autorelease];
    }

    cell.backgroundColor    = [UIColor whiteColor];

    UIFont *helvetica       = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    cell.textLabel.font     = helvetica;
    cell.textLabel.text     = [NSString stringWithFormat:@"Chapter %d", indexPath.row + 1];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    [contentView changeCurrentChapter:(indexPath.row + 1)];

    [self.view removeFromSuperview];
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.

    navBar.topItem.title    = [NSString stringWithFormat:@"%@ %d", self.Book.name, self.Chapter];
    chapterList.delegate    = self;

    [chapterList selectRowAtIndexPath:[NSIndexPath indexPathForRow:(self.Chapter - 1) inSection:0] animated:NO scrollPosition:UITableViewScrollPositionMiddle];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

It appears that the “touch” on the slider is being stopped when the table view recenters the selected item.

Any thoughts, workarounds, etc?

  • 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-23T22:45:32+00:00Added an answer on May 23, 2026 at 10:45 pm

    After spending way too long on this one, I ended up running it on an actual device. It worked fine…the hiccup did NOT occur.

    This is one bug that only occurs on the simulator. Therefore, it’s now a non-issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a tableviewcell I have a UISlider. If I move the slider knob, go
I have a custom UISlider and use the currentPlaybackTime to change values of an
In my app, I have a couple of UISlider instances to change various values.
i have IBOutlet uislider. i want it to show the value of slider when
I have a tableView with custom cells in it, each cell has a UISlider
I have to create my own customized slider. I am trying to change the
I have a UISlider acting as the scrubber. As the thumb is dragged I
I want to use a vertical UISlider . I have no idea about how,
I have a problem with the jQuery UI Slider. The issue also appears on
You may have seen JavaScript sliders before: http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html What I'm envisioning is a circular

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.