Wrapping ISRefreshControl for Ti.UI.TableView, Ti.UI.ListView, Ti.UI.ScrollView and Ti.UI.WebView on Titanium Mobile.
ISRefreshControl is iOS4-compatible UIRefreshControl.
- refreshControlEnabled default false, old version default ture
- Support the UIRefreshControl for Ti.UI.TableView, Ti.UI.ListView, Ti.UI.ScrollView and Ti.UI.WebView on iOS6
- Compatible UIRefreshControl on iOS4 and iOS5
$ git clone git@github.com:k0sukey/TiISRefreshControl.git
$ cd TiISRefreshControl
$ git submodule init
$ git submodule update
Open TiISRefreshControl.xcodeproj and edit the ISRefreshControl/ISGumView.m at line:46
// self.imageView.image = [UIImage imageNamed:@"ISRefresgControlIcon"];
self.imageView.image = [UIImage imageNamed:@"modules/be.k0suke.tiisrefreshcontrol/ISRefresgControlIcon.png"];
Execute build.py
$ ./build.py
There is no need a lot of event handling for pull-to-refresh. This is a very simply :D
var tableView = Ti.UI.createTableView({
refreshControlEnabled: true, // optional
refreshControlTintColor: '#f00', // optional
refreshControlBackgroundColor: '#00f', // optional
data: [
{ title: 'row0' },
{ title: 'row1' },
{ title: 'row2' },
{ title: 'row3' },
{ title: 'row4' },
{ title: 'row5' },
{ title: 'row6' },
{ title: 'row7' },
{ title: 'row8' },
{ title: 'row9' }
]
});
tableView.addEventListener('refreshstart', function(){
setTimeout(function(){
tableView.refreshFinish();
}, 5000);
});
<Window>
<ListView id="lists" defaultItemTemplate="list">
<Templates>
<ItemTemplate name="list">
<Label bindId="name" class="name"/>
</ItemTemplate>
</Templates>
<ListSection id="section" dataCollection="lists" dataTransform="doTransform">
<ListItem template="list" name:text="{name}"/>
</ListSection>
</ListView>
</Window>
var lists = Alloy.Collections.lists;
function doTransform(model) {
return model.toJSON();
}
$.lists.addEventListener('refreshstart', function(){
lists.fetch({
success: function(){
$.lists.refreshFinish();
},
error: function(){
$.lists.refreshFinish();
}
});
});
$.index.addEventListener('open', function(){
$.lists.refreshBegin();
});
$.index.open();
var lists = Alloy.Collections.lists = Alloy.createCollection('lists');
TiISRefreshControl enable or disable.
The tint color for the refresh control.
The background color for the refresh control.
getter / setter for refreshControlEnabled.
getter / setter for refreshControlTintColor.
getter / setter for refreshControlBackgroundColor.
A Boolean value indicating whether a refresh operation has been triggered and is in progress.
Tells the control that a refresh operation was started programmatically.
Tells the control that a refresh operation has ended.
Refresh starting event.
Refresh ending event.
The MIT License (MIT) Copyright (c) 2013 Kosuke Isobe, Socketbase Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.