[AC-2111] iOS: Touch events not working in custom table view rows
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2013-12-06T18:52:49.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | TouchEvents, iOS, iOS5, tableview |
Reporter | Ankit Thakur |
Assignee | Shak Hossain |
Created | 2012-10-18T04:26:28.000+0000 |
Updated | 2016-03-08T07:41:05.000+0000 |
Description
Hi all,
When we are creating custom rows, and setting either of the following values in table view options, then touch event is not working for iOS mobile app.
1. backgroundColor
2. scrollable
3. borderColor
4. borderRadius
5. borderWidth
6. headerView
/**
for iOS, if we are having any custom row, then touch events are not being called,
if any of the following properties are available in table view options.
*/
var backgroundColor = options['backgroundColor'];
var scrollable = options['scrollable'];
var borderColor = options['borderColor'];
var borderRadius = options['borderRadius'];
var borderWidth = options['borderWidth'];
var headerView = options['headerView'];
delete options['backgroundColor'];
delete options['scrollable'];
delete options['borderColor'];
delete options['borderRadius'];
delete options['borderWidth'];
delete options['headerView'];
/**
now create table without these options, then add listener,
then add table to window, and in last re-set these properties in table view
**/
var tableView = UI.Common.CommonViews.table.getTableView(options);
var tStart;
tableView.addEventListener('touchstart', function(e) {
Ti.API.info('touch start');
tStart = new Date();
});
tableView.addEventListener('touchend', function(e) {
var tEnd = new Date();
if (tEnd.getTime() - tStart.getTime() > Common.ConfigurationConstants.LONG_PRESS_TIME_GAP_CONSTANT) {
Ti.API.info('tableViewLongPressEvent');
window.fireEvent('tableViewLongPressEvent', e);
} else {
Ti.API.info('tableViewClickEvent');
window.fireEvent('tableViewClickEvent', e);
}
});
window.add(tableView);
/**
set earlier removed properties in table view
**/
tableView.backgroundColor = backgroundColor;
tableView.scrollable = scrollable;
tableView.borderColor = borderColor;
tableView.borderRadius = borderRadius;
tableView.borderWidth = borderWidth;
tableView.headerView = headerView;
return tableView;
Hi Ankit, Please could you change the test case to something we can run? Thanks!
As per the code shared, the touch event listeners on table rows are directly proportional to properties of tableview. Properties: 1. backgroundColor 2. scrollable 3. borderColor 4. borderRadius 5. borderWidth 6. headerView If we are setting the above mentioned properties, before adding touch event listeners, then those are not working.
Please change it to a runnable test case. Thanks.
Hello, We tested this issue the test code below. We can’t reproduce this issue. In our sample code, we have used all properties that you mentioned. Please let us know if you notice anything different. We will mark this "resolved" but wait for your feedback before closing this. Please keep us posted. Regards,
Testing Environment:
OS: MAC OS X 10.8.5 Ti SDK: 3.1.3 GA Ti CLI: 3.3.0 IOS simulator 7.0Test Code
Step to reproduces
1. Create a new project 2. Paste test code in app.js 3. Now run on iOS simulator 4. Click on TableView row 5. And check studio console 6. Console will update in event Thanks