简体   繁体   中英

Appcelerator Titanium 3.x/IOS7 Can not add a window as a child of a view

I have inherited an Appcelerator project and updating to the IOS7 SDK has broken a split view in iPad.
I am receiving this error [INFO] Can not add a window as a child of a view. Returning.
The code as far as I can tell is attempting to create and add the missing view to the window. I believe it may have something to do with this section of Appcelerators Migration Guide ! it referrers to IOS7 new window architecture. Everything else seems to being added to the window with no issues. I am not sure if this matters but it is an universla iPhone/iPad application. I really do not work with IOS applications or Appcelerator at all and I would appreciate any support.

    function StyledWindow(title) {
      var self = Ti.UI.createWindow({
        title     :title,
        backgroundImage : '/images/bg-window.png',
        barImage    : '/images/header.png',
        barColor    : '#e6c661',  // currently set to gold.  Blue is #14243d. This appears to only work on iOS 7
        navTintColor  : '#e6c661',  // sets text color for what used to be nav buttons
        tabBarHidden  : true,
        translucent   : false,    // This value removes the translucentsy of the header in iOS 7
        statusBarStyle  :Titanium.UI.iPhone.StatusBar.LIGHT_CONTENT,  // This sets the window title to white text.
      });

      return self;
    };
    var artWindow = new StyledWindow();
    var self = new StyledWindow('Articles');
    self.add(artWindow); // this is where the error occurs

Window object can't contain another Window object.

Instead of calling StyledWindow() twice, use Ti.UI.createView() and add it to top level window:

function StyledWindow(title) {
  var self = Ti.UI.createWindow({
    title: title,
    barImage    : '/images/header.png',
    barColor    : '#e6c661',
    navTintColor  : '#e6c661',
    statusBarStyle: Titanium.UI.iPhone.StatusBar.LIGHT_CONTENT,
  });

  return self;
};

var artWindow = new Ti.UI.createView({
  backgroundImage : '/images/bg-window.png',
});

var self = new StyledWindow('Articles');
self.add(artWindow);
self.open();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM