在 iPad 上 swiftUI 中工作表的显示不一致



我使用修饰符 .sheet(isPresent: ( 来呈现带有 SwiftUI 的视图。 但是在Iphone或Ipad上的结果并不相同。

这是两种不同的外观:在 iPad 上看 - 在苹果手机上看

我希望在Ipad上看到与iPhone相同的外观。这可能吗? 因为现在工作表在Ipad上一分为二(如图所示(

编辑: 我补充说:

NavigationView {
// ...
}
.navigationViewStyle(StackNavigationViewStyle())

它有效,但仍然存在一个小问题:小问题

编辑:这是工作表中的代码

Form{
Section(header: Text("Adresse").foregroundColor(Constants.colorTitle).fontWeight(.semibold)) {
VStack{
Text("Vous y êtes presque !").padding(.bottom,5)
Button(action: {
self.showShareFileActivity = true
}) {
Text("Télécharger le bon de visite à compléter. ").padding().foregroundColor(.white).font(Font.custom("Montserrat-Regular", size: 14)).background(Constants.colorTitle).cornerRadius(5)
}
.sheet(isPresented: $showShareFileActivity,
content: {
ActivityView(activityItems: [self.data] as [Any], applicationActivities: nil) })
}
HStack{
//                        Text(("Adresse du bien"))
//                        Spacer()
TextField("Adresse ", text: $createFileViewModel.file.adresse).font(.system(size: 14)).padding(8).background(Constants.colorLightGrey).background(RoundedRectangle(cornerRadius: 5).strokeBorder(Constants.colorPrimary,lineWidth: 1))
}
}

Section(header: Text("Pièces jointes").foregroundColor(Constants.colorTitle).fontWeight(.semibold)){
HStack {
Text("Bon de visite rempli")
if createFileViewModel.file.urlBonDeViste != "" {
Image(systemName: "checkmark.circle.fill").foregroundColor(.green).font(.system(size: 15, weight: .medium))
}
Spacer()
Button(action: {
self.showDocumentPicker = true
}) {
Image(systemName: "square.and.arrow.up").font(.system(size: 22, weight: .medium)).padding(.trailing,10)
}
.sheet(isPresented: $showDocumentPicker, content: {
DocumentPicker(urlBonDeVisite: self.$createFileViewModel.file.urlBonDeViste, userId: self.session.session!.uid, docId: self.createFileViewModel.file.idDocument)
})
}
VStack(alignment: .leading){
HStack {
Text("Plan cadastral")
if createFileViewModel.file.urlPlanCadastal != "" {
Image(systemName: "checkmark.circle.fill").foregroundColor(.green).font(.system(size: 15, weight: .medium))
}
Spacer()
Button(action: {
self.showImagePicker = true
}) {
Image(systemName: "square.and.arrow.up").font(.system(size: 22, weight: .medium)).padding(.trailing,10)
}
.sheet(isPresented: $showImagePicker, content: {
ImagePicker(isShown: self.$showImagePicker, from: "PlanCadastral", userId: self.session.session!.uid, docId: self.createFileViewModel.file.idDocument, urlPlanCadastral: self.$createFileViewModel.file.urlPlanCadastal, urlWebcarto: self.$createFileViewModel.file.urlWebcarto, photosSupplementaires: self.$createFileViewModel.file.urlsPhotosSupplémentaires)
})
}
if createFileViewModel.file.urlPlanCadastal != "" {
RemoteImageProfilePictureMedium(url: createFileViewModel.file.urlPlanCadastal, size: 75, colorStroke: Constants.colorPrimary).padding(.trailing, 5)
}
}

VStack(alignment: .leading){
HStack{
Text("Webcarto")
if createFileViewModel.file.urlWebcarto != "" {
Image(systemName: "checkmark.circle.fill").foregroundColor(.green).font(.system(size: 15, weight: .medium))
}
Spacer()
Button(action: {
self.showImagePicker = true
}) {
Image(systemName: "square.and.arrow.up").font(.system(size: 22, weight: .medium)).padding(.trailing,10)
}
.sheet(isPresented: $showImagePicker, content: {
ImagePicker(isShown: self.$showImagePicker, from: "Webcarto", userId: self.session.session!.uid, docId: self.createFileViewModel.file.idDocument, urlPlanCadastral: self.$createFileViewModel.file.urlPlanCadastal, urlWebcarto: self.$createFileViewModel.file.urlWebcarto, photosSupplementaires: self.$createFileViewModel.file.urlsPhotosSupplémentaires)
})
}
if createFileViewModel.file.urlWebcarto != "" {
RemoteImageProfilePictureMedium(url: createFileViewModel.file.urlWebcarto, size: 75, colorStroke: Constants.colorPrimary).padding(.trailing, 5)
}
}

VStack{
HStack {
Text("Photos supplémentaires")
if createFileViewModel.file.urlsPhotosSupplémentaires.count > 0 {
Image(systemName: "checkmark.circle.fill").foregroundColor(.green).font(.system(size: 15, weight: .medium))
}
Spacer()
Button(action: {
self.showImagePicker = true
}) {
Image(systemName: "square.and.arrow.up").font(.system(size: 22, weight: .medium)).padding(.trailing,10)
}
.sheet(isPresented: $showImagePicker, content: {
ImagePicker(isShown: self.$showImagePicker, from: "PhotosSupplementaires", userId: self.session.session!.uid, docId: self.createFileViewModel.file.idDocument, urlPlanCadastral: self.$createFileViewModel.file.urlPlanCadastal, urlWebcarto: self.$createFileViewModel.file.urlWebcarto, photosSupplementaires: self.$createFileViewModel.file.urlsPhotosSupplémentaires)
})
}
ScrollView(.horizontal, showsIndicators: false) {
HStack {
ForEach(createFileViewModel.file.urlsPhotosSupplémentaires, id: .self) { urlPhoto in
RemoteImageProfilePictureMedium(url: urlPhoto, size: 75, colorStroke: Constants.colorPrimary).padding(.trailing, 5)
}
}
}
}

if createFileViewModel.error != "" {
Text(createFileViewModel.error).font(.system(size: 14, weight: .semibold)).foregroundColor(.red).padding()
}
Button(action: createFileViewModel.goToNextStep) {
Text("Envoyer le dossier").frame(minWidth: 0, maxWidth: .infinity).frame(height: 50).foregroundColor(.white).font(.system(size: 14, weight: .bold)).background(Constants.colorButton).cornerRadius(5)
}
}

}
.navigationViewStyle(StackNavigationViewStyle())
.onAppear(perform: downloadPDF)

在 NavigationView上,将 StackNavigationViewStyle 设置为 navigationViewStyle:

NavigationView {
// ...
}
.navigationViewStyle(StackNavigationViewStyle())

最新更新