[ALOY-924] Alloy: Built-in loading widget fails to be added in controller whose top-level view is a navigation window
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-01-14T14:01:07.000+0000 |
Affected Version/s | Alloy 1.3.0 |
Fix Version/s | n/a |
Components | Widgets |
Labels | api, community, defect |
Reporter | David He |
Assignee | Unknown |
Created | 2014-01-05T10:18:39.000+0000 |
Updated | 2018-03-07T22:28:28.000+0000 |
Description
Below code snippet will fail
[ERROR] : Script Error {
[ERROR] : backtrace = "#0 () at :0";
[ERROR] : line = 5;
[ERROR] : message = "-[__NSDictionaryM krollObjectForBridge:]: unrecognized selector sent to instance 0xd94ffc0";
[ERROR] : sourceId = 234370688;
[ERROR] : sourceURL = "file:///Users/Tracyguan/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/2153BB00-6302-4AC9-88AA-580D5EBBA65D/alloyTester.app/alloy/controllers/nav_root_win.js";
[ERROR] : }
nav_win.xml
<Alloy>
<NavigationWindow id="nav" platform="ios">
<Window id="index" title="Job List" tabBarHidden="true" backgroundColor="black">
<LeftNavButton platform="ios">
<Button id="lBtn" style="Titanium.UI.iPhone.SystemButtonStyle.PLAIN" title="Job Status" onClick="closeW" />
</LeftNavButton>
<Button title="showLoading" onClick="load"/>
</Window>
</NavigationWindow>
</Alloy>
nav_win.js
function load() {
var loadIcon = Alloy.createWidget("com.appcelerator.loading");
$.index.add(loadIcon); //throw error
//$.nav.add(loadIcon); //throw error
}
Tony - Not sure how to reproduce this issue with Titanium SDK as it appears to be related to loading widget so moving it to Alloy project for diagnosis as we can reproduce it with the provided test case.
Your code is not properly using the Alloy APIs, both the original and updated test cases.
createWidget
returns a widget controller, not a UI component, which is whatadd()
expects. You need to change:to
and it works fine. In the future, try posting these types of questions to [Q&A](http://developer.appcelerator.com/questions/newest) (if you haven't already) before logging a ticket to the Titanium Community project.
Closing as invalid. If this is incorrect, please reopen.