How to show scrollbars permanently?


I’m curious if there is a method like showScrollbars to at least signal to the user that there is additional data present and that they need to scroll right? I’d like it if I didn’t have to put a string “Scroll right for more data” beneath every single chart in use. The other option is telling the client this is a training issue (this is an enterprise app) and they simply need to tell/train their users.

Thanks in advance!


Greetings Program!

Are you talking about the charts or grids? I’ve never used the charts but looking at the sample code, I don’t see any scroll indicators but they are on the grid.

If it’s the charts; in the chart docs I couldn’t see anything about scroll bars but I did mess around with the getting started app and added a sudo scroll bar:

// .h added SChartDelegate
@interface ViewController : UIViewController <SChartDelegate>

// .m assigned delegate and added sudo scroll bar image below the chart.
- (void) viewDidLoad
	[removed code]
	_chart.delegate = self;
	UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"graphic2.png"]];
	image.frame = CGRectMake(110.0, 725.0, 100.0, 25.0);
	image.tag = 99;
	[self.view addSubview:image];

- (void)sChartIsPanning:(ShinobiChart *)chart
	NSLog(@"sChartIsPanning %@", chart.xAxis);

	// Move the sudo scroll bar along with the panning.
	[self moveScrollBar:[chart.xAxis.axisRange.minimum floatValue]];

- (void)sChartDidFinishPanning:(ShinobiChart *)chart
	NSLog(@"sChartDidFinishPanning %@", chart.xAxis);
	// Final resting place of the sudo scroll bar.
	[self moveScrollBar:[chart.xAxis.axisRange.minimum floatValue]];

- (void)moveScrollBar:(float)x
	if (x < 0) x = 0;
	UIImageView *image = (UIImageView *)[self.view viewWithTag:99];
	if (image != nil)
		image.frame = CGRectMake(110.0+x, 725.0, 100.0, 25.0);

For the grid, since it’s an enterprise app, you might be able to use this solution here to access the scroll indicators of the grid scrollview:

Or, of course, add a sudo scroll bar :laughing:.



I’m speaking of the grid. It extends past where the user can view them (and this app is an enterprise internal app and the people using it aren’t too savvy).


Well the category in the link didn’t do much for iOS7 and in the end you’d end up having to create your own scroll bar.

This is using the Getting Started sample app and works very well. I did the vertical scroll bar but it’ll be easy enough to switch to horizontal; you’ll have to mess around with the calculation formulas a little to get them just right. I made it so that it covered the normal vertical scroll indicator.

// .h - added the UIScrollViewDelegate and SDataGridDelegate
@interface ViewController : UIViewController <SDataGridDataSource, UIScrollViewDelegate, SDataGridDelegate>

// .m - assigned delegate and added initial scroll bar image.
- (void) viewDidLoad
	[code removed]

	_shinobiDataGrid.delegate = self;

	UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"graphic2.png"]];
	image.frame = CGRectMake(755, -10.0, 15.0, 100.0);
	image.tag = 999;
	[_shinobiDataGrid addSubview:image];

	// Calculate the y point for the top of the scroll bar. Maybe there's a better way
	// to do the calculation but we need to make sure that it scrolls down at a ratio
	// relative to the screen and content height.
	float header = 120;
	float y = scrollView.contentOffset.y - header; // Account for header.
	float contentHeight = scrollView.contentSize.height;
	float frameHeight = scrollView.frame.size.height;
	float ratio = contentHeight / frameHeight;
	// Calculation fix. Changed this:
	// float scrollBarHeight = (contentHeight - frameHeight - (header * 2)) - ((contentHeight - frameHeight) / ratio) + 60;
	// To below but although it works fine with 50 records, with 250, it's a little off
	// so the formula still needs tweaking to get it right for any number of records.
	float scrollBarHeight = frameHeight - ((contentHeight - frameHeight) / ratio) + header;

	NSLog(@"y = %f", y);
	NSLog(@"contentHeight = %f : frameHeight = %f", contentHeight, frameHeight);
	NSLog(@"ratio = %f : new y = %f", ratio, y/ratio);
	NSLog(@"scrollBarHeight = %f", scrollBarHeight);
	[self moveScrollBar:y/ratio scrollBarHeight:scrollBarHeight];

- (void)moveScrollBar:(float)y scrollBarHeight:(float)scrollBarHeight
	UIImageView *image = (UIImageView *)[_shinobiDataGrid viewWithTag:999];
	if (image != nil)
		image.frame = CGRectMake(755, y, 15.0, scrollBarHeight);

Again, the values you’ll have to tweak for your own and you’ll have to change the location and image size for covering the horizontal scroll indicators.



Cool, I’ll give it a shot