Titanium JIRA Archive
Alloy (ALOY)

[ALOY-924] Alloy: Built-in loading widget fails to be added in controller whose top-level view is a navigation window

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2014-01-14T14:01:07.000+0000
Affected Version/sAlloy 1.3.0
Fix Version/sn/a
ComponentsWidgets
Labelsapi, community, defect
ReporterDavid He
AssigneeUnknown
Created2014-01-05T10:18:39.000+0000
Updated2018-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
}

Comments

  1. Ritu Agrawal 2014-01-14

    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.
  2. Tony Lukasavage 2014-01-14

    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 what add() expects. You need to change:
       var loadIcon = Alloy.createWidget("com.appcelerator.loading");
       
    to
       var loadIcon = Alloy.createWidget("com.appcelerator.loading").getView();
       
    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.
  3. Eric Merriman 2018-03-07

    Closing as invalid. If this is incorrect, please reopen.

JSON Source