我的Swift代码中有这个简单的代码
let PostPage = PostView()
navigationController?.pushViewController(PostPage, animated: true)
class PostView: UIViewController
此代码执行它应该执行的操作,即显示PostView
,但是当显示此视图时,我希望UINavbar的标题将被更改,并且将显示后退按钮。但这些都不会发生
window?.rootViewController = UINavigationController(rootViewController: TabNavigator())
答案 0 :(得分:3)
好像你正在将rootViewController从NavigationController更改为ViewController。
HBox root = new HBox();
ArrayList<String> items = new ArrayList<String>();
String textLine;
Button btn = null;
try
{
InputStream inputStream = JavaFX_Paths.class.getResourceAsStream("/imagens/lista_imagens.txt");
InputStreamReader inputReader = new InputStreamReader(inputStream);
BufferedReader bufferReader = new BufferedReader(inputReader);
while ((textLine = bufferReader.readLine()) != null)
items.add(textLine);
bufferReader.close();
inputReader.close();
inputStream.close();
}
catch (IOException ex)
{
Logger.getLogger(JavaFX_Paths.class.getName()).log(Level.SEVERE, null, ex);
}
for (int i = 0; i < items.size(); i++)
{
Image img = new Image(getClass().getResourceAsStream("/imagens/" + items.get(i) + ".png"));
btn = new Button();
btn.setId(items.get(i));
btn.setGraphic(new ImageView(img));
root.getChildren().addAll(btn);
}
因此rootViewController不再是navigationController。