Titanium Hyperloop casting ListView to UIScrollView to use flashScrollIndicators

64 views Asked by At

I want to flash the scrollbars of a ListView in Axway / Appcelerator Titanium. So I cast a Titanium ListView to a iOS UIScrollView and then try to call the flashScrollIndicators method on it, but I get an exception. Does anyone now how to accomplish this? See my code below:

-- View

<Alloy>
  <Window onOpen="onWindowOpen">
    <ListView id="listView">
    etc...

-- Controller

// After displaying the ListView I call:
var UIScrollView = require('UIKit/UIScrollView');
var listView = UIScrollView.cast($.listView);
listView.flashScrollIndicators();
1

There are 1 answers

0
Richard Lustemberg On

The $.listView object is natively a subclass of UIView, not a UIScrollView. It contains a UITableView as a child view. You could access the tableview like this:

var UIView = require('UIKit/UIView');
var listView = UIView.cast($.listView);//you cast it to be able to access it's native properties
listView.tableView.flashScrollIndicators();

Haven't tested it but I guess it should work.

When in doubt about the type of a Titanium UI element, just go and check the source code by opening the project compiled in the build/iphone directory. Open it with XCode and search for the header file.