I am working on an app that I would like to provide a welcome screen when launched. Not a Launch Screen in iOS, but more of a welcome screen that you see after an app has updated to a new version. Does anyone know how apple does this with their apps? Do they use a Sheet View that's tied to a version number? I have attached a couple of screen shots of when I opened Keynote after it updated. Any help on where to start would be much appreciated.
Post
Replies
Boosts
Views
Activity
Good morning!
I am developing an iOS app that gets its data from an API and displays it in a list. The list item view has NavigationLink embedded in it that sends users to a detail view. In this detail view, I have some Text views but the issue I am running into is a WKWebView that I have implemented to display some HTML that's is retrieved from the API call.
The WKWebView displays the HTML just how I want it to. The issue I have is in the HyperLinks that are displayed in the WKWebView. When a user taps on a link, it opens inside of the web view. Instead of opening in the web view, I would like this link to open in the user's default web browser. I have searched and found ways of doing this in older versions of Swift using classes but my web view is initialized inside of a struct that conforms to the UIViewRepresentable protocol.
I don't know how to get links to open in the browser instead of the WebView so any help would be appreciated. Here is the code for my WebView that is being used on the details page.
struct NewsItemWebView: UIViewRepresentable {
// HTML from API Call
var text: String
// Method to create the View
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
// Method to update the View by changing properties of the WebView
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.isOpaque = false
uiView.backgroundColor = UIColor.white
uiView.loadHTMLString(text, baseURL: nil)
}
}
Here is how I am implementing the WebView on DetailView
NewsItemWebView(text: item.PageContent)
.frame(height: 450)
Any help on how I can make links open in a browser would be great. Thanks in advance.
This is an interesting issue I am having with a custom app I am making in Xcode using SwiftUI.
I have a Swift file called BillView. In this file, I have some code that displays data retrieved from the CoreData Stack in a List. The issue I am having is when I add a new record, the List reflects that there is an additional row but it has the same displayed text as the one above it. If I continue to add records, they all show the same text as the first row. I have gone through the code and banged my head against the wall until it now hurts. Can someone please help me discover why each row isn't showing its unique data? I have attached the code from the BillView Swift file below.
//
// BillView.swift
// Budget Me
//
// Created by Charles Vincent on 8/3/22.
//
import SwiftUI
import CoreData
struct BillRow: View {
var bill: Bill
var body: some View {
Text(bill.merchant ?? "No merchant given")
}
}
struct BillView: View {
@Environment(\.managedObjectContext) private var viewContext
@FetchRequest(
entity: Bill.entity(),
sortDescriptors: [NSSortDescriptor(keyPath: \Bill.date, ascending: true)],
animation: .default)
private var bills: FetchedResults<Bill>
@State var linkActive = false
var body: some View {
NavigationView {
List {
ForEach(bills){ bill in
BillRow(bill: bill)
}
.onDelete(perform: deleteBills)
}
.navigationTitle("Bills")
.background(
NavigationLink(destination: AddBillView(), isActive: $linkActive) {}
)
.toolbar {
ToolbarItem(placement: .automatic) {
Button(action: {
linkActive = true
}) {
Image(systemName: "plus")
}
}
}
}
}
private func deleteBills(offsets: IndexSet) {
withAnimation {
offsets.map { bills[$0] }.forEach(viewContext.delete)
do {
try viewContext.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
let nsError = error as NSError
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
}
}
}
}
struct BillView_Previews: PreviewProvider {
static var previews: some View {
BillView()
}
}