Hi,
I'm trying to figure out how to manually position a subview within a view using SwiftUI.
For example, when the user taps the screen, I want to place a small icon on the screen at the position tapped.
I know how to get the coordinates of the tapped location but I don't know how to either place a view there or move an existing view already being shown to that location.
In a regular non-SwiftUI app I can set the frame, or set up constraints. I don't know what the best approach is in SwiftUI.
Thanks.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Is it possible to set a silent local notification?
Is there any way to scan for Bluetooth advertising messages while in the background if the device doesn't advertise any service IDs?
I've been asked to build and app that does this. The device in question is an off-the-shelf medical alert button (my company doesn't make the device and can't alter its firmware). Upon examining it, I find that it does not advertise any service IDs nor does it offer any ability to connect, it works purely by sending advertising packets.
I'm told that there are Android apps that can work with this device even while in the background. I checked the iOS bluetooth docs to see if any new scanning capabilities had been recently added, but could not find anything.
Thanks,
Frank
Is it possible to monitor the accelerometer or gyroscope when running in the background?
My goal is to develop an app that detects sudden accelerations, like if the user fell down stairs, or was in a car accident.
Thanks,
Frank
I'm trying to send my app silent push notifications by setting the "content-available" flag to 1 in the notification payload. This works, but there is a problem: if my app is not running in the foreground, the notification is visible on the home screen. I don't want this: I just want the app to see it, without waking up the screen or alerting the user.
If the app is open when the notification comes in, it works as expected; I receive the notification inside my app, and iOS does not display any alert or banner.
I configured my app with the "Remote Notifications" background mode.
What am I doing wrong?
Hi,
I'm working with a BLE device manufacturer on a new device for which I'm tasked with developing the iOS app.
The hardware developer told me: "In response to a Scan request (from a phone or other device) the BLE stack is configured to include a device identifier". The device identifier is something I need to see in the advertising packet before I connect to the device.
I don't know what a "Scan request" is. Is this something I have to specifically ask for in my app? Is it something iOS does automatically?
Thanks,
Frank
I can't get my latest iPhone app to run in portrait mode only. In Xcode I've checked only the box that says "Portrait" under Device Orientation, and I've also examined the Info.plist file to ensure that there aren't any hidden settings for other orientations.
I've also tried checking or un-checking iPad, and checking "Requires Full Screen" when that option appears. No matter what I do, when I run the app on my phone and rotate the screen, the interface rotates.
What am I doing wrong?
I've got an iOS project that I've been working on for some months. Just recently, I started seeing a compiler error to the effect that "Referencing instance requires that X conforms to Equatable". It shows up in places where you'd expect something to be Equatable, such as the argument to firstIndexOf: on an array.
The class in question is written in Swift, but descents from an Objective-C base class. I know there are some issues with how Equatable interacts with Obj-C but I think I've done it right. The base class extends NSObject, and the subclass implements both the isEqual function and the static == function. (I don't think the latter is necessary but I included it just in case).
I've tried explicitly including "Equatable" in the definition of the subclass but the compiler rejects this as "Redundant conformance to protocol". I'm not exactly sure how that works since NSObject doesn't extend Equatable but I guess Swift considers them equivalent.
Here's where things get super weird though. Xcode still builds and runs the project despite the compiler error, and the code runs, and it works. I even put a breakpoint in the isEqual function to make sure it was getting called. Also, when I clean and rebuild the project, the compiler error often disappears for some time, reappearing hours or days later. So I think this must be some kind of bug in Xcode or Swift itself.
What do you think?
Frank
Views A and B are equal in width (set up via a constraint). The actual width will vary at runtime.
What I want to do is arrange view A such that it is horizontally centered on B but offset to the left by 1/10th of the total width.
In other words, if views A and B were 100 units in length, I'd want A to be positioned 10 units to the left of B. If the width were 150 units then the A position would be 15 to the left, etc.
I thought I could do this with either a leading constraint or a centerX constraint using a multiplier of 0.9, but it isn't working out the way I want.
What's the best solution?
I want to customize or limit the typing suggestions for a UISearchBar input to a list of known words that exist within the material that is being searched. How is this done?
Thanks,
Frank
How do I disable the predictive text feature (word suggestions) of the keyboard when used with a UISearchBar?
Do string functions such as "replacingOccurrences" and "trimmingCharacters" always return a new string, even if the old string did not need to be modified?
In other words -- if I'm doing a large number of "replacingOccurrences" in my app but only a small number of the strings actually contain the sequence I want to replace, should I check to see if the sequence exists before calling replacingOccurrences, in order to avoid an unnecessary string allocation?
I would guess that Swift would return the same string if it didn't require any modifications, but the documentation just says "Returns a new string".
Thanks,
Frank
I'm getting the dreaded "Failed to prepare the device for development" error when I connect my iPhone running iOS 15 to the latest version of Xcode. I've tried rebooting both devices. How do I fix this?
I'm trying to save a Dictionary to UserDefaults. My Dictionary is defined as [String:Data]. Since both String and Data are property objects, I expected this to work, but it doesn't: my app blows up with a "this class is not key-value coding compliant" error.
Is this a bug, or am I doing something wrong?
Hi,
My customer wants to do the thing where an app store URL is advertised which contains a referral code. When a user follows the link, it should take them to the app store to install the app, and then when the app is installed, it should be able to get access to the referral code in the original URL.
I know such a thing was possible at one time because I remember talking to some of my colleagues about it, but I have never done it myself and whatever my coworkers did 8 years ago in Objective-C probably doesn't work anymore.
Can someone let me know how to do this, or at least, let me know what the correct name for this procedure is so I can look it up? Thanks.