0

我無法讓TableView保持放置狀態。如下面的代碼所示,TableView駐留在第二個窗口中,而第二個窗口本身駐留在NavigationWindow中。我的問題是:是否有可能使NavigationWindow成爲模態,如果是這樣,爲什麼TableView第二次打開?我錯過了什麼嗎?Titanium Appcelerator:TableView在第二次打開時在NavigationWindow中向上滑動

編輯:它不只是特定於tableviews,這是發生任何視圖添加到窗口。

我使用3.2.3.GA

var win = Ti.UI.createWindow({ backgroundColor: '#ffffff', title: 'first window' }); 
var button = Ti.UI.createButton({ title: 'click me', left: 0, right: 0 }); 
var button2 = Ti.UI.createButton({ title: 'click me', left: 0, right: 0 }); 
var win2 = Ti.UI.createWindow({ backgroundColor: '#ffffff', leftNavButton: button2 }); 
var tableView = Ti.UI.createTableView({ top: 0, left: 0, right: 0, bottom: 0 }); 
var navigationWindow = Ti.UI.iOS.createNavigationWindow({ window : win2, modal: true}); 

var row = Ti.UI.createTableViewRow({ title: 'test' }); 

tableView.setData([row]); 

win2.add(tableView); 
win.add(button); 

win.open(); 

button.addEventListener('click', function() { 
    navigationWindow.open(); 
}); 

button2.addEventListener('click', function() { 
    navigationWindow.close(); 
}); 

first open second open

回答

0

你應該改變一些代碼:這是一個例子,如何添加一個模態窗口與NavigationController和裏面的tableView 。

// create modal window 

    ModalWindow = Ti.UI.createWindow({ 
     title : 'This is my Window' 
    }); 

// Add TableView and Add it to your Window 

    var TableView = Ti.UI.createTableView({ top: 0, left: 0, right: 0, bottom: 0 }); 
    ModalWindow.add(TableView); 

// Add a NavigationControllerWindow, and add your Modal Window to it 

    var NavWindow = Ti.UI.iOS.createNavigationWindow({ 
     modal : true, 
     window : ModalWindow 
    }); 

// Open it modal  

    button2.addEventListener('click', function() { 
     NavWindow.open({ 
      modalStyle : Ti.UI.iPhone.MODAL_PRESENTATION_PAGESHEET 
     }); 
    }); 
+0

嗨derdida,據我可以告訴我們的代碼之間的唯一區別是'Ti.UI.iPhone.MODAL_PRESENTATION_PAGESHEET'常量。添加後,問題仍然存在。 – Peter 2014-08-29 09:09:11

+0

你可以提供截圖嗎? – derdida 2014-08-29 09:11:46

+0

添加了兩個屏幕截圖,第一個顯示了第一次打開模式(這是我要做的)。第二次打開模式(第二個屏幕截圖),桌面視圖向上滑動。 – Peter 2014-08-29 09:23:58

相關問題