小编mig*_*uan的帖子

LocationManager经常调用onLocationChanged?

我已经设置了LocationManager以每2分钟获取当前位置:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 120000, 0, this);
Run Code Online (Sandbox Code Playgroud)

这工作正常,onLocationChanged按预期每2分钟调用一次.然而,似乎 2分钟在10-40(随机量)第二跨度上多次调用它.我记录了onLocationChanged中收到的每个位置,所以这里有一些示例来了解发生了什么:

17:30

GPS 32.0 50.66318929195404 10.735434293746948 0.0 2010.08.07 17:30:10
GPS 32.0 50.66315710544586 10.735423564910889 0.0 2010.08.07 17:30:14
GPS 32.0 50.66314101219177 10.735418200492859 0.0 2010.08.07 17:30:17
GPS 32.0 50.66314101219177 10.735418200492859 0.0 2010.08.07 17:30:20
GPS 24.0 50.66313564777374 10.735418200492859 0.5 2010.08.07 17:30:24
GPS 32.0 50.663098096847534 10.735573768615723 0.0 2010.08.07 17:30:28         
GPS 32.0 50.663065910339355 10.735611319541931 0.0 2010.08.07 17:30:31
Run Code Online (Sandbox Code Playgroud)

然后我在2分钟内没有更新.

17:32

GPS 32.0 50.661821365356445 10.737022161483765 1.0 2010.08.07 17:32:39
GPS 16.0 50.66170871257782 10.737043619155884 1.8200275 2010.08.07 17:32:45
GPS 24.0 50.661579966545105 10.737027525901794 1.25 2010.08.07 …
Run Code Online (Sandbox Code Playgroud)

android

8
推荐指数
2
解决办法
2万
查看次数

非半透明的UITabBar创建奇怪的灰色条

使用 SwiftUI,我有几个嵌套在 TabBar 内的 NavigationView。这样做的原因是我想更改每个 NavigationView 的标题以反映所选选项卡,但我找不到其他方法来执行此操作。另外,对于我的客户来说,UITabBar 的背景颜色为纯白色非常重要。为此我设置了UITabBar.appearance().isTranslucent = false,否则它显示为灰色。然而,一旦我这样做,我就会在 UITabBar 上方看到一条奇怪的灰线。我怎样才能摆脱这个?

struct ContentView: View {
    
    init() {
            
        UITabBar.appearance().backgroundColor = UIColor.white
        UITabBar.appearance().isTranslucent = false
    }
    
    var body: some View {
        TabView {

        NavigationView {
            
            Text("First tab")
                .padding(10)
                .background(Color.white)
                .navigationBarTitle(Text("First tab"), displayMode: .inline)
        }
        .tabItem {
            Text("First tab")
        }
            
        NavigationView {
            
            Text("Second tab")
                .padding(10)
                .background(Color.white)
                .navigationBarTitle(Text("Second tab"), displayMode: .inline)
        }
        .tabItem {
            Text("Second tab")
        }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

TabBar上方的灰色条

swift swiftui

2
推荐指数
1
解决办法
1213
查看次数

标签 统计

android ×1

swift ×1

swiftui ×1