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!
Post not yet marked as solved
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.
Post not yet marked as solved
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,
Post not yet marked as solved
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!
Hi,
I'm trying to create a ViewController that extends UIHostingController and host an AttachmentView there. Also, I would like to pass an environment object to the AttachmentView, but I get a compile error because the type of rootView does not match what I specify in UIHostingController.
How can I get this code to compile?
Thanks!
Post not yet marked as solved
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,
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,
Hi,
The Background Tasks framework introduced in iOS 13 is also available in Mac Catalyst 13.0 according to the documentation.
However, the same code that runs on iOS 13 using the BGAppRefreshTaskRequest class does not work in my Mac Catalyst app.
So I was wondering whether or not the Background Tasks framework is supposed to work in a Mac Catalyst app.
Thanks!
Post not yet marked as solved
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.
There's a feature to hide sensitive data in complications on Apple Watch, but is this feature available for third-party complications in watchOS 7?
Thanks!
Post not yet marked as solved
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
Post not yet marked as solved
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
Post not yet marked as solved
Hi,I'm using the new UNMutableNotificationContent to display a local notification on Mojave. I want to display something similar to a calendar notification, where I want to have a "Close" button that does nothing, along with options such as "Notify Me in 5 Mins" and "Notify Me Tomorrow", which I was able to do using the UNNotificationCategory.The problem is that I cannot create a simple "Close" button that does nothing. Upon clicking the "Close" button, the app launches automatically. How can I create a close button with no action?Any insight is appreciated. Thanks!
Post not yet marked as solved
Whenever a user notification fires, I see the "Now" label at the top-right corner of the notification. How can I customize it to something like "1 day ago" (past) or "in 30 minutes" (future) like the Calendar or Reminders apps do?The "Now" label:http://cdn.osxdaily.com/wp-content/uploads/2016/10/tons-of-notifications-iphone-clear-them-all.jpgActually, the "Now" label changes to "5 mins ago" if I leave the notification for 5 minutes, but it still does not give an option to customize it (e.g., instead of "5 mins ago", maybe I want "Past Due"). And it also does not let me show future dates (e.g., showing a notification now for a meeting in 30 minutes, in which case I might want something like "in 30 minutes" or "Time to leave") I looked at both "UNMutableNotificationContent" and "UNCalendarNotificationTrigger" classes but they don't seem to contain such property.Thanks!