小编yaw*_*eix的帖子

带有列表的 SwiftUI 自定义导航栏

我做了一个类似于下面看到的苹果的列表,但我真的不喜欢 UInavigation 栏的样子。理想情况下,我希望它更小或将其隐藏,以便我可以将自己的观点放在那里。

苹果列表视图

我试图通过使用苹果外观 api 中的以下内容来隐藏它

init() { 
    UINavigationBar.appearance().backgroundColor = .green
    UINavigationBar.appearance().isHidden = true
   }
Run Code Online (Sandbox Code Playgroud)

与拥有巨大的标题相比,即使拥有这样的导航栏也会更理想

导航栏标题

但这没有影响,有没有人有任何建议或想法,我可以如何自定义它以使其更像我想要的那样?

uinavigationbar swiftui

6
推荐指数
1
解决办法
7534
查看次数

如何在读取xml文件时处理文件结尾

所以我正在读取长度未知的xml文件,并将每个元素读入列表结构.现在,一旦我到达文件的末尾,我继续阅读,这会导致异常.现在我只是抓住这个例外并继续我的生活,但是有更清洁的方法吗?

try
{
    while(!textReader.EOF)
    {
        // Used to store info from each command as they are read from the xml file
        ATAPassThroughCommands command = new ATAPassThroughCommands ();                      
        // the following is just commands being read and their contents being saved
        XmlNodeType node = textReader.NodeType;                                             

        textReader.ReadStartElement( "Command" );
        node = textReader.NodeType;
        name = textReader.ReadElementString( "Name" );
        node = textReader.NodeType;
        CommandListContext.Add(name);
        command.m_Name = name;
        command.m_CMD = Convert .ToByte(textReader.ReadElementString("CMD" ),16);
        command.m_Feature = Convert .ToByte(textReader.ReadElementString("Feature" ),16);

        textReader.ReadEndElement(); //</command>
        m_ATACommands.Add(command);
    }
}
catch ( Exception …
Run Code Online (Sandbox Code Playgroud)

c# xml file-io

5
推荐指数
2
解决办法
1421
查看次数

附加文件导致覆盖(Java)

所以我正在创建一个CSV文件,每次动作发生时我都想将数据写入文件.我遇到的问题是它会在第二次进入时覆盖数据.如何将数据添加到文件末尾?

 public boolean save_to_csv(){

    //check if directory exists, if not create the folder
    File folder = new File(Environment.getExternalStorageDirectory() + "/HKA_CAL");
    //Environment.getExternalStorageDirectory() get the location of external storage
    boolean success = true;
    if(!folder.exists())
    {
       success = folder.mkdir();
    }         
    if (success) 
    { 
        //success is true if folder has successfully been created
        //now we can create/check if the file exists

        File stored_hka = new File(Environment.getExternalStorageDirectory()+"/HKA_CAL/Stored_values.csv");
        boolean file_existed=true;

        try{
            if(!stored_hka.exists()){
                stored_hka.createNewFile();
                file_existed=false;
            }
            FileOutputStream fOut = new FileOutputStream(stored_hka);
            OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
            if(!file_existed){ …
Run Code Online (Sandbox Code Playgroud)

java file new-operator

4
推荐指数
1
解决办法
2834
查看次数

如何更改导航栏中的背景或颜色?

目前我找不到任何方法来更改 SwiftUI 中导航栏的颜色/背景。有小费吗?

navigationbar swiftui

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

swiftui ×2

c# ×1

file ×1

file-io ×1

java ×1

navigationbar ×1

new-operator ×1

uinavigationbar ×1

xml ×1