{ "id": "126036", "key": "TIMOB-16414", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "15931", "description": "2014 Sprint 05", "name": "2014 Sprint 05", "archived": true, "released": true, "releaseDate": "2014-03-14" }, { "id": "15932", "description": "2014 Sprint 05 API", "name": "2014 Sprint 05 API", "archived": true, "released": true, "releaseDate": "2014-03-14" }, { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-03-03T23:21:33.000+0000", "created": "2014-02-06T20:30:15.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "module_window", "qe-testadded", "supportTeam" ], "versions": [ { "id": "15593", "description": "Release 3.1.3", "name": "Release 3.1.3", "archived": true, "released": true, "releaseDate": "2013-09-18" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" }, { "id": "15856", "description": "Release 3.2.1", "name": "Release 3.2.1", "archived": false, "released": true, "releaseDate": "2014-02-10" } ], "issuelinks": [], "assignee": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2014-07-31T07:49:02.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h3. Issue\r\n\r\nIn iOS when calling the removeAllChildren() method to a view part of a window that hasn't been open theres no action performed and the children of the view remain, in Android calling the same method before the window is open the children are removed correctly.\r\n\r\nCalling the view.remove(); before the window is open works correctly.\r\n\r\nh3. Test Case\r\n\r\nClassic\r\napp.js\r\n{code}\r\nvar win = Ti.UI.createWindow({backgroundColor:'green'});\r\n\r\nvar v = Ti.UI.createView({\r\n\tlayout:'vertical'\r\n});\r\nvar bt1 = Ti.UI.createButton({\r\ntitle:'bt1',\r\ntop:10,\r\n});\r\nvar bt2 = Ti.UI.createButton({\r\ntitle:'bt2',\r\ntop:10});\r\n\r\nv.add(bt1);\r\nv.add(bt2);\r\nwin.add(v);\r\n\r\nTi.API.info('removing all children for content. #children: ' + v.children.length);\r\nv.removeAllChildren();\r\nTi.API.info('... AFTER removing all children for content. #children: ' + v.children.length); \r\n\r\nwin.open();\r\n{code}\r\n\r\nAlloy\r\n\r\nindex.js\r\n{code}\r\nfunction setupMainWindow() {\r\n Ti.API.info('removing all children for content. #children: ' + $.content.children.length);\r\n $.content.removeAllChildren();\r\n Ti.API.info('... AFTER removing all children for content. #children: ' + $.content.children.length);\r\n var pickOne = Math.floor(Math.random()*5);\r\n\r\nswitch(pickOne){\r\n case 0:\r\n $.content.add($.pageOne);\r\n break;\r\n case 1:\r\n $.content.add($.pageTwo);\r\n break;\r\n case 2:\r\n $.content.add($.pageThree);\r\n break;\r\n case 3:\r\n $.content.add($.pageFour);\r\n break;\r\n case 4:\r\n default:\r\n $.content.add($.pageFive);\r\n break;\r\n}\r\n$.getView().open();\r\n};\r\n\r\nsetupMainWindow();\r\n{code}\r\n\r\nindex.xml\r\n{code}\r\n\r\n \r\n \t\r\n \r\n \r\n \r\n \r\n \r\n \r\n \t\r\n \r\n\r\n{code}\r\n\r\nh3. Console log\r\n\r\nCalling win.open() after the v.removeAllChildren() leaves the children.\r\n{code}\r\n[INFO] : Focusing the iOS Simulator\r\n[INFO] : Application started\r\n[INFO] : testcase/1.0 (3.2.0.GA.d9182d6)\r\n[INFO] : removing all children for content. #children: 2\r\n[INFO] : ... AFTER removing all children for content. #children: 2\r\n{code}\r\n\r\nCalling win.open() before the v.removeAllChildren() correctly removes the children.\r\n{code}\r\n[INFO] : Application started\r\n[INFO] : testcase/1.0 (3.2.0.GA.d9182d6)\r\n[INFO] : removing all children for content. #children: 2\r\n[INFO] : ... AFTER removing all children for content. #children: 0\r\n{code}\r\n\r\nh3. Workaround\r\n\r\nA simple loop can be used to read the children of a view and remove them, either if the window has been open or not.\r\n\r\n{code}\r\nfunction clearView(view){\r\n\tTi.API.info('removing all children for content. #children: ' + view.children.length);\r\n\tvar viewLength = view.children.length-1;\r\n\tfor(var i = viewLength;i >= 0; i--){\r\n\t\tview.remove(view.children[i]);\r\n\t}\r\n\tTi.API.info('... AFTER removing all children for content. #children: ' + view.children.length);\t\r\n};\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "iOS: removeAllChildren is not working until window is open", "creator": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Product: Titanium SDK\r\nTitanium SDK: Mobile 3.1GA\r\nPlatform OS: iOS", "comment": { "comments": [ { "id": "291774", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~mcota] Can you please add the Alloy use case to this ticket?", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-02-06T21:52:17.000+0000", "updated": "2014-02-06T21:52:17.000+0000" }, { "id": "295322", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Pull pending against master\r\nhttps://github.com/appcelerator/titanium_mobile/pull/5408", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-03-03T20:33:15.000+0000", "updated": "2014-03-03T20:33:15.000+0000" }, { "id": "301234", "author": { "name": "pagarwal", "key": "pagarwal", "displayName": "Priya Agarwal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing the issue as working as expected.\r\nremoveAllChildren method working fine before window open.\r\n\r\nTest Environment:\r\n\r\nAppc-Studio:3.2.3.201404151910\r\nsdk:3.3.0.v20140416200257\r\nacs:1.0.14\r\nalloy:1.3.1\r\nnpm:1.3.2\r\ntitanium:3.2.3-beta\r\ntitanium-code-processor:1.1.1-beta1\r\nxCODE:5.1.1\r\nDevice:Nexus7(v4.4.2),Iphone5(v7.1)", "updateAuthor": { "name": "pagarwal", "key": "pagarwal", "displayName": "Priya Agarwal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-17T09:56:33.000+0000", "updated": "2014-04-17T09:56:33.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }