Hello,
I am using SwiftUI ShareLink to share an image with Instagram app, but when I select "Story" option in share interface, an error happens, "Error: Something went wrong".
Has anyone had this problem? Is there a solution?
Thanks
Thanks
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Post
Replies
Boosts
Views
Activity
The dividing lines of List Section overlap, which is uncomfortable to look at.
Look at the line under "Incomplete"
I have an iOS App which looks great on iPhone, portrait only, which makes a lot of use of UITableViews.
On iPad those tables look stretched out in Landscape.
On MacOS with Apple Silicon the app can be resized to any size and the table views look very stretched. There are views in the App which users want to resize so limiting app size not an option.
I've been modifying the app's table views to limit their width and centre them using constraints.
This isn't easy, it's a lot of work as UITableViewController doesn't allow for constraining the table width. Or does it?
So I've changed them to UIViewControllers with UITableView imbedded in the root UIView with constraints. Looks really nice.
Now I've just run into the limitation that static tables, which I have a number of, aren't allowed to be embedded. So how can I limit the width of them?
I really don't want to add a lot of dynamic code.
Please tell me there's an simpler, more elegant method to what really makes a much more aesthetically pleasing UI on iOS App running on iPad and MacOS?
TIA!
Hi,
I'm new here. I have an app that I want to refresh a few variables at midnight. What ways can i go about doing this?
I have an AppDelegate started, but I'm not sure how to make it work, yet.
Is there an easy way to make it update?
I have a swiftui view with Button(intent: ) and using UIHostingViewcontroller to use it in UIKit. The problem is that button not works in uikit but normal button(without intent works)
Hi guys,
I've been this app for quite a while and I wanted to add audio to it but I've encountered a strange bug. Whenever I try to play the audio from the testing device, it prints out that the audio file cannot be found. I've checked multiple times the names and the code and I get no errors there whatsoever. I have no idea what might be causing this. Here's a part of the code:
`import SwiftUI
import AVFoundation
struct Card: Identifiable {
let id = UUID()
let heading: String
let description: String
let imageName: String
let detailDescription: String
let sonification: String
}
struct ExplorepageUI: View {
@State private var selectedCard: Card?
@State private var showMore = false
@State private var currentIndex = 0
@State private var currentCards: [Card] = []
let galaxies = [
Card(heading: "The Mice Galaxies",
description: "They’re located about 300 million light-years away in the constellation Coma Berenices.",
imageName: "TheMiceGalaxiesHubble",
detailDescription:"""
Their name refers to the long tails produced by tidal action, the relative difference between gravitational pulls on the near and far parts of each galaxy, known here as a galactic tide. It is a possibility that both galaxies, which are members of the Coma Cluster, have experienced collision, and will continue colliding until they coalesce. The colors of the galaxies are peculiar. In NGC 4676A a core with some dark markings is surrounded by a bluish white remnant of spiral arms. The tail is unusual, starting out blue and terminating in a more yellowish color, despite the fact that the beginning of each arm in virtually every spiral galaxy starts yellow and terminates in a bluish color. NGC 4676B has a yellowish core and two arcs; arm remnants underneath are bluish as well.
The galaxies were photographed in 2002 by the Hubble Space Telescope. In the background of the Mice Galaxies, there are over 3000 galaxies, at distances up to 13 billion light-years.
""",
sonification: "SonificationoftheMiceGalaxies"),
`class MusicPlayer: ObservableObject {
private var audioPlayer: AVPlayer?
func playSound(named sonificationFileName: String){
if let url = Bundle.main.url(forResource: sonificationFileName, withExtension: "mp3"){
print("✅ Found audio file at: \(url)")
audioPlayer = try? AVPlayer(url: url)
audioPlayer?.play()
print("🎵 Audio should now be playing!")
} else {
print("❌ Audio file not found: \(sonificationFileName).mp3")
}
}
func pause(){
audioPlayer?.pause()
}
}
I'm not sure where to report this, so here it is.
If you have a list of items and you make them clickable and movable, moving one or more items in the list and then clicking will cause them to move. This is yet another reason that SwiftData needs to track onMove.
Minimal reproducible code:
//
// ContentView.swift
// exampleBug
//
// Create a new project.
// Replace the default Item class with the one below, and replace ContentView with its class below
// Run the app and add a few items a few seconds apart so you can tell them apart.
// Drag an item to a new position in the list.
// Click one of the checkboxes and watch the list positions change for no reason!
//
import SwiftUI
import SwiftData
@Model
final class Item {
var timestamp: Date
var checkbox: Bool = false
init(timestamp: Date) {
self.timestamp = timestamp
}
}
struct ContentView: View {
@Environment(\.modelContext) private var modelContext
@State private var editMode = EditMode.inactive
@Query private var items: [Item]
var body: some View {
NavigationStack {
List {
ForEach(items) { item in
HStack {
Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))
Button("", systemImage: item.checkbox ? "checkmark.circle.fill" : "circle") {
item.checkbox.toggle()
try? modelContext.save()
}
}
}
.onMove(perform: { indices, newOffset in
var theItems = items
theItems.move(fromOffsets: indices, toOffset: newOffset)
})
}
.environment(\.editMode, $editMode)
.moveDisabled(false)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
EditButton()
}
ToolbarItem {
Button(action: addItem) {
Label("Add Item", systemImage: "plus")
}
}
}
}
}
func addItem() {
withAnimation {
let newItem = Item(timestamp: Date())
modelContext.insert(newItem)
}
}
func deleteItems(offsets: IndexSet) {
withAnimation {
for index in offsets {
modelContext.delete(items[index])
}
}
}
}
#Preview {
ContentView()
.modelContainer(for: Item.self, inMemory: true)
}
code-block
I made an account on this site for the sole reason to post this.
I can not stand the IOS 18 photo app, to put it bluntly its sucks, it's made the app unusable.
I was nice, I'd thought I'd give it a month or two but no, it still sucks.
I wish I could uninstall IOS 18 solely cause of it.
I hate the UI, its utterly unintuitive.
I have a very simple SwiftUI app, works fine on iOS, crashes on macOS:
struct ContentView: View
{
@State var testStr: String = ""
@State var selection: TextSelection? = nil
var body: some View
{
VStack
{
TextField("Test", text: $testStr, selection: $selection)
.onChange(of: selection) {print("selection changed")}
}
.padding()
}
}
• Start app, write something in the TextField and move the cursor around.
iOS: "selection changed"
Mac: nothing (Bug ?)
• double click on some word
both Mac and iOS: "selection changed"
• write some more in the TextField
iOS: selection changed
Mac: crash
Any idea what I am doing wrong?
Gerriet.
I'm creating a simple TipViewStyle based on sample code but it fails to compile. It displays: Type 'MyViewStyle' does not conform to protocol 'TipViewStyle'
When I choose the Fix option, it adds this line:
`type alias Body = type'
What should the type be here?
struct MyTipViewStyle: TipViewStyle {
func makeBody(config: Configuration) -> some View {
VStack {
config.title
config.message?
}
}
I have a map application that needs to show a line (representing a direct route) that is above everything, including annotations. This is important because the map has lots of annotations (possibly hundreds) and the line is representing a route from point to another. With that many annotations being on top the line / route is basically useless because you can't see it.
I've looked at things like MKOverlayLevel but it only supports .aboveRoads or .aboveLabels. Is there a way to set the z-axis of a map overlay so that it truly is on top of everything else on the map, including annotations? And if not directly in MapKit, what other options might I have?
Worth noting that I'm targeting 16.4 and above, so that's my limitation on this
When I try to install cocoapods I get this error:
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.12.2%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+tried%3A+%27%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.12.2%2Flib%2Fffi_c.bundle%27+%28mach-o+file%2C+but+is+an+incompatible+architecture+%28have+%27x86_64%27%2C+need+%27arm64e%27+or+%27arm64%27%29%29%2C+%27%2FSystem%2FVolumes%2FPreboot%2FCryptexes%2FOS%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.12.2%2Flib%2Fffi_c.bundle%27+%28no+such+file%29%2C+%27%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.12.2%2Flib%2Fffi_c.bundle%27+%28mach-o+file%2C+but+is+an+incompatible+architecture+%28have+%27x86_64%27%2C+need+%27arm64e%27+or+%27arm64%27%29%29+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.12.2%2Flib%2Fffi_c.bundle&type=Issues
If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don't forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods...
Searching for inspections failed: undefined method `map' for nil:NilClass
robertsantovasco@iMac L1 demo %
I typed "install pod". There's pages of errors above that. Here is my podfile:
platform :ios, '9.0'
target 'L1 demo' do
Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'RealmSwift'
end
Please help. Thank you.
We are using an imbedded WKWebView in a SwiftUI view. There are links within the pages being viewed - they are company pages - and some link to other pages as well as open named (or unnamed) browser tabs.
In our implementation, when there is a named (or unnamed) link to another browser tab, the view does not do anything.
Any ideas on how to allow tabs to open in some manner and allow the users to access the links?
Hi I think I found an issue with SwiftUI List on iOS 18.0 and 18.1
Using the ContentView from the code block below: if you try to drag and drop the globe image onto the blue rows, things work fine on both iOS 17 and 18 with either List or VStack.
However if you first drag and drop the image onto the Files app and then drag the newly created PNG file back into our app, it won't work on iOS 18 with the blue row inside the List. Also there's no visual feedback when hovering that blue row (unlike the one inside the VStack).
I've tried various view modifiers but no luck so far. Any help is appreciated.
Thank you.
FB15618535
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.resizable()
.scaledToFit()
.frame(height: 100)
.draggable(Image(systemName: "globe"))
List {
Color.gray
.frame(height: 100)
Color.blue
.frame(height: 100)
.dropDestination(for: Image.self) { _, _ in
print("List dropped")
return true
}
}
VStack {
Color.gray
Color.blue
.dropDestination(for: Image.self) { _, _ in
print("VStack dropped")
return true
}
}
}
.padding()
}
}
I have ran into an issue that is illustrated by the code in the following GitHub repository.
https://github.com/dougholland/ColorTest
When a SwiftUI color originates from the ColorPicker it can be persisted correctly and renders the same as the original color. When the color originates from the MapFeature.backgroundColor, it is always rendered with the light appearance version of the color and not the dark appearance version. The readme in the GitHub repo has screenshots that show this.
Any assistance would be greatly appreciated as this is affecting an app that is in development and I'd like to resolve this before the app is released.
If this is caused by a framework bug, any possible workaround would be greatly appreciated also. I suspect it maybe a framework issue, possibly with some code related to the MapFeature.backgroundColor, because the issue does not occur when the color originates from the ColorPicker.
This is a critical bug with Document-Based Apps (SwiftData). If you download the WWDC 2023 sample code for"Building a document-based app using SwiftData" , open it in Xcode 16.1, and run it on an iOS 18+ simulator, you'll encounter a major issue. When you exit a document and reopen it, you'll find that the changes you just made were not saved.
iOS 18 has effectively rendered last year's WWDC 2023 sample code obsolete!
Has anyone managed to successfully save data in a Document-Based App using SwiftData?
ScrollView scrolling works on Mac Catalyst apps with a Trackpad just fine but the same cannot be said for mouses with scroll wheels.
Is there any way to achieve scrolling with scroll wheels?
Following instructions from ChatGPT, I'm trying to rearrange the order of rows in a UITableView.
- (void)tableView:(UITableView *)tableView performDropWithCoordinator:(id<UITableViewDropCoordinator>)coordinator {
NSIndexPath *destinationIndexPath = coordinator.destinationIndexPath ?: [NSIndexPath indexPathForRow:self.items.count inSection:0];
[tableView performBatchUpdates:^{
for (UITableViewDropItem *dropItem in coordinator.items) {
NSString *movedItem = dropItem.dragItem.localObject;
if (movedItem) {
NSIndexPath *sourceIndexPath = dropItem.sourceIndexPath;
if (sourceIndexPath) {
[self.items removeObjectAtIndex:sourceIndexPath.row];
[self.items insertObject:movedItem atIndex:destinationIndexPath.row];
[tableView moveRowAtIndexPath:sourceIndexPath toIndexPath:destinationIndexPath];
}
}
}
} completion:nil];
}
Xcode is complaining that UITableViewDropItem does not exist.
The class is in all the documentation, it is just not showing up when needed!
Suggestions?
I tried several times to use the PhotosPickerItem loadTransferable function with the goal of receiving some progress value especially when loading large video media.
However, the Progress object returned by the function has always isIndeterminate == true and so doesn't have any progress value to observe.
Is there some way to make it work ? Some configuration I might have overlooked ? Or is it just not working
I might have to revert back to the UIKit photo picker because of this
Hi,
I programmed an app to draw cards from a deck. After a card is drawn it is hidden from the deck. The drawn state is a property of a card struct in an array inside a deck struct.
This worked well in the past since iOS 14. Since Xcode 16 this does not work as before anymore.
This is the Card struct with a Boolfor the drawn state:
struct Card: Codable, Identifiable, Equatable, Hashable {
var isDrawn: Bool
…
}
The cards are stored in an array that is inside a CardDeck struct among other properties:
struct CardDeck: Codable {
var cards: [Card] = []
var cardSpacing: CGFloat
…
mutating func hideCard(card: Card) {
if let cardIndex = self.cards.firstIndex(of: card) {
self.cards[cardIndex].isDrawn = true
}
}
}
The deck is a published property of an observable DeckStore class for permanent storage:
class CardDeckStore: ObservableObject {
@Published var deck: CardDeck = CardDeck()
…
}
The DeckStore class is @StateObject in the App struct:
@main
struct CardApp: App {
@StateObject var store = OpaliaCardDeckStore()
var body: some Scene {
WindowGroup {
ContentView(deck: $store.deck)
}
}
}
Here is the simplified DrawCardsView where I present and draw the cards:
struct DrawCardsView: View {
@Binding var deck: CardDeck
var body: some View {
// Was a NavigationView before
NavigationStack() {
HStack(spacing: deck.cardSpacing) {
ForEach($deck.cards) { $card in
if card.isDrawn {
CardBackView(card: card)
.hidden()
}
else {
NavigationLink(destination: DrawnCardView(card: card, deck: $deck)) {
CardBackView(card: card)
}
}
}
}
}
}
}
To hide a drawn card, hideCard() is called in the DrawnCardView:
struct DrawnCardView: View {
var card: Card
@Binding var deck: CardDeck
@State var drawnCard: DrawnCard = .init()
var body: some View {
DrawnCardSimpleView(drawnCard: self.drawnCard)
.onDisappear(perform: {
deck.hideCard(card: self.card)
})
}
}
I am not a pro in programming and there are better solutions to program this, but this worked until I upgraded to Xcode 16. Now it seems the isDrawn state of a card does not update the DrawCardsView right away anymore. A drawn card is not hidden and still present when returning to DrawCardsView from DrawnCardView. After tapping the same card again or another update of the UI, the card will then be hidden.
I do not know the reason. It seems the binding of the isDrawn state inside an element of the card array in the observable object is not working anymore. Other properties of the observable object like cardSpacing do work as expected.
I can empty the cards array and fill it with new cards without problems in the DrawCardsView.
I eliminated the ForEach loop by addressing the array elements directly, but to no avail. I tried different solutions I found on the internet, but nothing worked.
I was under the impression that every change in an observable object would update the UI.
Any ideas for a explanation/solution?
Thanks,
Christian