k0sukey / tiisrefreshcontrol Goto Github PK
View Code? Open in Web Editor NEWWrapping ISRefreshControl for Ti.UI.TableView and Ti.UI.ListView on Titanium Mobile.
License: Other
Wrapping ISRefreshControl for Ti.UI.TableView and Ti.UI.ListView on Titanium Mobile.
License: Other
Would be useful if it could be enabled in a webView too. I have an app which loads content in a webView that should be updateable.
Looks like it's possible: http://stackoverflow.com/questions/13379815/use-uirefreshcontrol-for-uiwebview
self.refreshControl = [(id)[[ISRefreshControl alloc] init] seems to create a memory leak
autorelease seems to be needed since ISRefreshControl *refreshControl is a retain property
-(void)initializeState
{
[super initializeState];
if (self)
{
self.refreshControl = [(id)[[ISRefreshControl alloc] init] autorelease]; // autorelease needed ?
[self.refreshControl addTarget:self
action:@selector(refreshStart)
forControlEvents:UIControlEventValueChanged];
}
}
The scrollbar disappear when using it in a webview.
When I try to drag the list down to see the refreshcontrol it just releases the list immediately which makes it impossible to drag it down enough to refresh.
Test case:
function createWin() {
var win = Ti.UI.createWindow();
var list = Ti.UI.createListView({
refreshControlEnabled: true
});
list.addEventListener('refreshstart', function () {
setTimeout(function () {
list.refreshFinish();
}, 1000);
});
win.add(list);
return win;
}
var win = Ti.UI.iPad.createSplitWindow({
detailView: createWin(),
masterView: Ti.UI.createWindow()
});
win.open();
Using d22dbde
Is there a way to turn this off on lists that don't need it?
What would be ideal is to opt in this control on list view or table view creation
It seems like having multiple ListViews with TiISRefreshControl loaded at once makes them interfere with each other. This makes the second loaded window with a ListView not getting events or having any of the methods working.
I'm using the NappDrawer module to have multiple windows open at once. The first one is visible if you swipe right. The refresh control works there and hides after 1s. While in the second main view it does not, and keeps spinning forever.
var NappDrawer = require('dk.napp.drawer');
function createWin() {
var win = Ti.UI.createWindow();
var list = Ti.UI.createListView({
refreshControlEnabled: true
});
list.addEventListener('refreshstart', function () {
console.log('list1 refreshstart');
setTimeout(function () {
console.log('list1 refreshstart:done');
list.refreshFinish();
}, 1000);
});
win.add(list);
return win;
}
function createWin2() {
var win = Ti.UI.createWindow();
var list = Ti.UI.createListView({
refreshControlEnabled: true
});
list.addEventListener('refreshstart', function () {
console.log('list2 refreshstart');
setTimeout(function () {
console.log('list2 refreshstart:done');
list.refreshFinish();
}, 1000);
});
win.add(list);
return win;
}
var win = NappDrawer.createDrawer({
leftWindow: createWin(),
centerWindow: createWin2(),
closeDrawerGestureMode: NappDrawer.CLOSE_MODE_ALL,
openDrawerGestureMode: NappDrawer.OPEN_MODE_ALL,
leftDrawerWidth: 200
});
win.open();
Full runnable testcase here.
Using d22dbde
I built the module using 3.1.3.v20130906144623 and tried using it in my app (also uses the same SDK)
The refresh events are not fired. Works on 3.1.2.GA perfectly fine. Known issue?
What would be a possible fix?
I hear 3.1.3.GA releases today or tomorrow.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.