If you add four rows to the first section of a table view, sometimes on the simulator,ipod, or ipad 1 & 2 appear different in the sections of a tableview. If you add only two rows everything is fine, when adding four new rows two are added to the correct section, the other two to the following.
1.Run the code below.
Following should now happen: If you click the first "Show all" row (First section, first row), then rows with News 1.1 huhuhuhu, News1.2 will be appended in the first section and 1.3 & 1.4 will be new first rows in the second section.
If you do the same with the second section, then everything will be alright, because only two addional rows will be appended.
//Here's the first window...
var first = Ti.UI.createWindow({
backgroundColor:"#fff",
title:"My App"
});
/*Some data*/
var myData = [[
[{
"group": "Aktuelles",
"headline": "News1.1 hip hip hurra",
"teaser": "Teaser for News...",
"content": "Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ... LAST",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Aktuelles",
"headline": "News1.2 bl bla",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Aktuelles",
"headline": "News1.3",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Aktuelles",
"headline": "News1.4",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},
{
"group": "Aktuelles",
"headline": "News1.1 huhuhuhu",
"teaser": "Teaser for News...",
"content": "Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ... LAST",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Aktuelles",
"headline": "News1.2",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Aktuelles",
"headline": "News1.3",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Aktuelles",
"headline": "News1.4",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
}
],
[{
"group": "Fach",
"headline": "News2.1",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Fach",
"headline": "News2.2",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Fach",
"headline": "News2.3",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Fach",
"headline": "News2.4",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Fach",
"headline": "News2.3",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Fach",
"headline": "News2.4",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
}
],[{
"group": "Sonstiges",
"headline": "News3.1",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Sonstiges",
"headline": "News3.2",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Sonstiges",
"headline": "News3.3",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
},{
"group": "Sonstiges",
"headline": "News3.4",
"teaser": "Teaser for News...",
"content": "Some more text about ...",
"leftImage": "images/newsPlaceholder.png",
"image": "images/newsPlaceholder.png",
"type": "news"
}
]
]
]
yh = {};
yh.ui = {};
yh.ui.createOverviewData = function(_data){
var tVdata = [];
for(var group in _data){
var tVG = Ti.UI.createTableViewSection({
headerTitle: _data[group][0].group,
_groupID: group
})
var _gData = _data[group].slice(0,4);
if(_data[group].length > 4){
var allEntries = Ti.UI.createTableViewRow({
backgroundColor: '#fc0000',
color: '#fff',
className: "allEntries",
hasDetail: true,
title: "Show all"
});
tVG.add(allEntries);
}
var tRows = yh.ui.createOverviewRows(_gData,0);
for(var r in tRows){
tVG.add(tRows[r]);
}
tVdata.push(tVG);
}
return tVdata;
};
yh.ui.createOverviewRows = function(_data,_indexInt){
var rows = [];
for(var entry in _data){
var tVR = Ti.UI.createTableViewRow({
className: "overviewRow",
hasChild: true,
height: 55,
_id: Number(_indexInt)+Number(entry),
indentionLevel: 1,
layout: 'vertical',
leftImage: _data[entry].leftImage,
dataType: _data[entry].type
});
var hl = Ti.UI.createLabel({
font: {fontSize: 14, fontWeight: 'bold'},
height: 15,
left: 70,
text: _data[entry].headline,
top: 2
});
var ct = Ti.UI.createLabel({
bottom: 0,
font: {fontSize:12,fontWeight: 'normal'},
height: 30,
left: 70,
text: _data[entry].teaser
});
// Ti.API.info(hl);
tVR.add(hl);
tVR.add(ct);
rows.push(tVR);
}
return rows;
}
yh.ui.createOverviewList = function(_data){
var tVdata = yh.ui.createOverviewData(_data);
var tV = Ti.UI.createTableView({
data: tVdata,
editable: false,
left: 0,
style: Ti.UI.iPhone.TableViewStyle.GROUPED
});
tV.addEventListener('click',function(e){
if(e.source.className == 'allEntries'){
var nData = _data[e.section._groupID].slice(4);
var r = yh.ui.createOverviewRows(nData);
var p = e.index+(e.section.rowCount-1);
var j = 0;
for(var j in r){
var index = Number(p)+Number(j);
tV.insertRowAfter(index,r[j]);
if(j == r.length-1){
tV.deleteRow(e.index);
}
}
}else{
// Some other code to display a detail view.
}
})
return tV;
};
first.add(yh.ui.createOverviewList(myData[0]));
first.open();
Tested on the iOS simulator with 2.1GA, issue still reproducible.
Subject line of this ticket is poorly written as it does not provide any meaningful information.
I have been able to reproduce this issue with the following environment; iPhone 7 (10.2) MacOS 10.11.6 (15G31) Studio 4.9.0.201705021158 Ti SDK 6.1.0.v20170519131839 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.7.0_80
Was unable to reproduce the issue with : MacOS 10.14.4 Ti SDK 8.0.0 GA Appc CLI 7.0.10 Ti CLI 5.1.1 Xcode 10.2 Node 8.11.3 Java 10.0.2_13