Tutorial :TableViewController doesn't flash scroll indicators even if the table is bigger that the view



Question:

I've got a weird problem with a TableViewController. In the doc it says that a tableViewController deals also with the method -flashScrollIndicators when the table is "oversized" respect the visible area.

My app consists in 3 nav controller loaded in a tab controller. Each nav controller has as root view controller a subclass of a table view controller. Each "model" is populated from a plist file, that loads its contents into an array in the -viewDIdLoad, later everything is passed to the table. Everything is loaded programmatically no IB.

I've found out in my app that when it loads the first view (a nav controller with a table view controller as root) the scroll bar isn't flashing even if the number of cell it's great enough. If I choose another tab, that loads another nav controller (with a t.v.c. as root) scroll bar isn't shown again. When I press the tab corresponding to the first nav controller loaded the scrollbar flashes.

So I've tried to make it flash programmatically but no way, the code seems simple:

[self.tableView flashScrollIndicators];  

I've tried to put it almost everywhere. First in the -viewDidLoad (As suggested in the doc), then in viewDidAppear and in -viewWillAppear. Also tried use that code tring to cast the view of the t.v.c. as a table view.

[((UITableView*)self.view) flashScrollIndicators];  

..without result.

I've started looking at Apple sample and I've found that in Apple's table view custom sample (the one with different times) scroll bar doesn't flash also there. Tested both on sim and device.

Is a bug?, is there a correct way to show it programmatically? Can someone help me? Regards, Andrea


Solution:1

Or more concisely:

- (void)viewDidAppear:(BOOL)animated {    [super viewDidAppear:animated];    [self.tableView performSelector:@selector(flashScrollIndicators) withObject:nil afterDelay:0];  }  


Solution:2

I had exactly the same problem. I got around it in the end by putting a delayed selector in the viewDidAppear: method. Weirdly, I can set it to 0 seconds and it still works fine.

- (void)viewDidAppear:(BOOL)animated  {      [super viewDidAppear:animated];        [self performSelector:@selector(flashTableScrollIndicators) withObject:nil afterDelay:0.0];  }    - (void)flashTableScrollIndicators  {      [self.tableView flashScrollIndicators];  }  


Solution:3

It is not displayed when you show section index titles.

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView;   


Solution:4

My solution was to send the "flashScrollIndicators()" message with a slight delay using "dispatch_after":

let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.4 * Double(NSEC_PER_SEC)))    dispatch_after(delayTime, dispatch_get_main_queue(),   { () -> Void in       myScrollView.flashScrollIndicators()   })  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »