Post

Replies

Boosts

Views

Activity

How to prevent automatic scrolling of UIScrollView during drag & drop?
Hi,When dragging a view inside UIScrollView using UIDragInteraction/UIDropInteraction, the scroll view *automatically* scrolls as you drag your view near the edge of the screen. How can you prevent this behavior? I want to disable *only* the automatic scrolling, not the scrolling itself, so that the user can scroll with the second finger if he so chooses. I know I can disable scrolling using isScrollEnabled, but this will also disable the user-initiated scrolling. Thanks.
3
1
7.3k
Apr ’19
EKEventStore.refreshSourcesIfNecessary() on watchOS
Hi, Is there any way to refresh EKEventStore in Watch app? On iOS, you can call EKEventStore.refreshSourcesIfNecessary() to update the event store, but unfortunately this method is not available on watchOS. Is there any alternative way to refresh calendar events and reminders? I find that sometimes events and reminders don't sync well in Apple Watch. Thank you and best regards, Kaz
0
0
492
Jun ’20
EKReminder sort order
Hi, I would like to know if there's a way to get the sort order of reminders as they appear in the Reminders app. As you know, you can re-order reminders in Reminders app, but it seems that there's no way to get this ordering information using EventKit API. Thank you and best regards, Kaz
0
0
452
Jun ’20
How to add/test my widget in Notification Center in macOS Big Sur?
I'm running the latest macOS Big Sur beta 9, and I have an AppKit app and added a widget extension using Xcode 12.2 beta 2. I can run my widget using WidgetKit Simulator and it's working great. However, when I click the date/time on the menu bar to show the Notification Center and click the "Edit Widgets" at the bottom, I don't have my app listed in the list of apps. I tried copying my app's executable and put it in the "Application" folder, but the app still does not show up. So how can I add/test my widget in Notification Center? Thank you.
3
0
1.1k
Oct ’20
barTintColor not working in iOS 15
Hi, When I run the following code in application(_ :didFinishLaunchingWithOptions) in iOS 15, the bar color turns transparent (thus, showing the black background underneath), while the same code works fine in iOS 14.5: UINavigationBar.appearance().isTranslucent = false UINavigationBar.appearance().barTintColor = .red Here's the screenshots of Simulators running iOS 14.5 and iOS 15: I'm using Xcode 13 on macOS Big Sur 11.4. Thanks!
24
0
82k
Jun ’21
How to specify different list style in .listStyle() based on current device?
public var body: some View { List { ... } .listStyle(isPhone ? .plain : .sidebar) } When I write code like above, I get a compile error: "Member 'sidebar' in 'PlainListStyle' produces result of type 'SidebarListStyle', but context expects 'PlainListStyle'" It looks like the root cause is: Protocol 'ListStyle' can only be used as a generic constraint because it has Self or associated type requirements How can I solve this problem? Thanks,
2
0
1.1k
Jul ’21
Where to create View Model (or observed object) in SwiftUI?
In SwiftUI, is it a good idea to create a view model (or observed object) in a View? For example, if I write a code like this: struct AView: View { ... public var body: some View { ... ForEach(...) { ... otherView } } private var otherView: some View { let model = OtherViewModel() return OtherView().environmentObject(model) } } I guess this will re-create OtherViewModel every time AView is refreshed, so maybe this is not a good approach after all? I thought about creating it in the constructor of AView, but if otherView is created multiple times using ForEach like the example above, it's difficult to know ahead of time how many of these models I need to create. Any suggestion is highly appreciated! Thanks,
3
0
928
Jul ’21
Deselect List with animation in SwiftUI
Hi, I'm having a hard time trying to solve this impossibly small problem in SwiftUI. I have a list like this: struct ContentView: View { var body: some View { List { Button(action: { print("hello") }, label: { Text("Hello") }) } } } And every time I tap on it, the row deselect without animation, but I want the same effect as UITableView.deselectRow(at:animated:). Why is this so hard or am I missing something? I don't want to use NavigationLink because I only want to execute code upon tap, not navigating to other view, unless it's possible to only execute code using NavigationLink... Thanks,
1
0
870
Jul ’21
How to use iOS15-specific modifiers in SwiftUI on iOS 14 and earlier?
There are many new iOS15-specific modifiers that were added in SwiftUI. For example, we have a .focused() modifier, which can be used like this: TextField("Username", text: $username) .focused($focusedField, equals: .username) However, this code fails to compile if the app supports iOS 14 and earlier. How can I make this code to compile? Ideally, I'd like to do something like this: TextField("Username", text: $username) #if os(iOS, 15.0, *) .focused($focusedField, equals: .username) #endif But obviously this won't work because #if os() can only specify the target OS, not the version.. Thanks!
2
0
5.2k
Sep ’21
Xcode 14 Beta 3: Mac app icon not showing in macOS Ventura
Hi, I have an AppKit-based Mac app which was originally released in 2017. Since then, I've been constantly adding new features and now, I'm trying to add WeatherKit and other new features in macOS Ventura. The problem is that Xcode 14 beta 3 fails to show my app's icon on the Dock: The app icon is shown properly in Xcode and also in Finder: When I open the exact same Xcode project and run it in Xcode 13/Monterey, the app icon is shown properly in the Dock. Any help is appreciated! Best, Kaz
1
0
1k
Jul ’22