I have a SplitView that loads a map
controller/view into the detail window and a projects
controller/view into the master window.
The projects controller displays a Collection in a TableView. It initially displays a loading view that fades out on load. Depending on whether or not there are models in the Collection, either the TableView or a "no results" View is shown (by setting the other one's visible property to false).
The map controller is created in the callback of a Ti.Geolocation.getCurrentPosition
function, passing the latitude and longitude as arguments, which the controller uses to set the map's region property.
When the app opens, the dialog box asking to confirm the use of location services pops up, which seems to prevent the projects TableView from showing. The loading view just fades away to show a blank window. If I close the app and restart it, now that location services have already been confirmed, the dialog box does not pop up and so the projects TableView shows as expected.
I'll try to include some very stripped down code excerpts:
// main.js (loaded after index.js, contains the SplitView var projectsView = Alloy.createController('projects').getView(); if(Ti.Platform.osname == 'iphone') { $.mainWinPhone.add(projectsView); } else if(Ti.Platform.osname == 'ipad') { $.splitMasterWin.add(projectsView); Ti.Geolocation.purpose = ''; Ti.Geolocation.getCurrentPosition(function(e) { var mapView = Alloy.createController('map', { latitude: e.coords.latitude, longitude: e.coords.longitude }).getView(); $.splitDetailWin.add(mapView); }); }
// projects.js (Retrieves projects from remote server and adds them to a Collection // Inside HTTPClient to get projects... if(data.length) { // has projects projectList.add(projects); // Add array of models (projects) to Collection (projectList) $.noResults.visible = false; // Hide noResults View, leaving only the TableView visible } else { projectList.reset(); // Empty the Collection $.tableContainer.visible = false; // Hide the TableView, leaving only the noResults View visible }This is for iOS only and using SDK 3.2.3.GA.