Activity Indicator not centering in Web View

You must Login before you can answer or comment on any questions.

Hi folks,

Got an issue when I load a web view using an activity indicator using the latest SDK on iOS.

When the page loads the indicator sits in the top left hand corner.

Do I need to set the coordinates somewhere first? I'm sure you didn't used to have to do that. Maybe I'm wrong!

Here is my code in full:

var window = Titanium.UI.currentWindow;
 
function loadShows() {
 
    var webview = Titanium.UI.createWebView({
        //backgroundColor:"#fff",
        backgroundImage:'images/background.png',
        url:'http://www.mylinkgoeshere.com'
    });
 
    window.add(webview);
 
    var toolActInd = Titanium.UI.createActivityIndicator();
 
    toolActInd.style = Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN;
    toolActInd.font = {fontFamily:'Helvetica Neue', fontSize:15,fontWeight:'bold'};
    toolActInd.color = '#fff';
    toolActInd.message = 'Loading Tickets...';
    window.setToolbar([toolActInd],{animated:true});
    toolActInd.show();
    setTimeout(function()
    {
        toolActInd.hide();
        window.setToolbar(null,{animated:true});    
    },3000);
 
 
}
 
loadShows();
 
// refresh option
var refreshBtn = Titanium.UI.createButton({
    systemButton: Ti.UI.iPhone.SystemButton.REFRESH,
    backgroundColor:'#000'
});
 
refreshBtn.addEventListener('click', function() {
    loadShows();
});
 
window.setRightNavButton(refreshBtn);

Thanks!

1 Answer

Accepted Answer

Hi simon, you have added the activity indicator in the window toolbar, thats why it is shown in the top left corner of the screen... add it to window directly.

try :
 
window.add(toolActInd);
 
in place of:
 
window.setToolbar([toolActInd],{animated:true});

— answered 7 months ago by Ashish Nigam
answer permalink
1 Comment
  • I did want to keep the toolbar ideally, but your suggestion fixes the issue.

    Cheers.

    — commented 7 months ago by Simon Hume

Your Answer

Think you can help? Login to answer this question!