列表视图在SwiftUI中抖动 [英] List views jittering in SwiftUI

查看:154
本文介绍了列表视图在SwiftUI中抖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主要的详细视图,可以使用完全普通的SwiftUI导航一系列顺序列表,我注意到了两件事.

I have a master detail view that navigates a series of sequential lists using totally vanilla SwiftUI and I'm noticing two things.

  1. 当您通过导航链接访问列表时,行宽度是否抖动?
  2. .navigationBarTitle在新视图完全显示在屏幕上之前不可见吗?

似乎这些事情都没有发生?想知道是否有人有任何想法(附带视频和代码).

Seems like neither of these things are suppose to happen? Wonder if anyone has any ideas (video and code attached).

有关问题的视频: https://www.dropbox. com/s/5jq3e8chay6hsy5/jitter.mov?dl = 0

UserList.swift:

import SwiftUI

struct UserList: View {
    var body: some View {
        NavigationView {
            List(userData) { this in
                NavigationLink(destination: CityList(user: this, cities: this.cities)) {
                    UserRow(user: this)
                }

            }
            .navigationBarTitle(Text("Users"))
        }
    }
}

UserRow.swift:

import SwiftUI

struct UserRow: View {
    var user: UserModel
    var body: some View {
        VStack(alignment: .leading) {
            Text(user.firstName + " " + user.lastName)
                .font(.headline)
        }
    }
}

CityList.swift:

import SwiftUI

struct CityList: View {
    var user: UserModel
    var cities: [CityModel]

    var body: some View {
        List (cities) { this in
            NavigationLink(destination: TownList(city: this, towns: this.towns)) {
               CityRow(city: this)

            }.navigationBarTitle(Text(self.user.firstName + self.user.lastName))
        }
    }
}

CityRow.swift:

import SwiftUI

struct CityRow: View {
    var city: CityModel

    var body: some View {
        VStack(alignment: .leading) {
            Text(city.name)
                .font(.headline)
        }
    }
}

推荐答案

第三次是他们的魅力,那就是他们怎么说.

Well third time's the charm, that's how they say.

抖动仅发生在模拟器上,我遇到了同样的问题.然后我在手机上安装了该应用程序,并且运行良好.只需在模拟器上忽略它即可.

The jittering is only on simulator, i had the same problem. Then i installed the app on a phone and it worked perfectly fine. Just ignore it on the simulator..

据我所知,标题的问题是-只是模拟器上的一个错误,我在手机上没有这些问题.

And the problem with the title is -as far as i know- also just a bug on the simulator, i don't have these issues on a phone.

这篇关于列表视图在SwiftUI中抖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆