Posts

Post not yet marked as solved
0 Replies
98 Views
I'm working on a navigation app and I would like to snap the userLocation to the MKRoute's Polyline much like how Apple does in Apple Maps. I've added the route's MKPolyline to my MKMapView and it looks great, the user's location is just usually not centered on the road or is off to the side a bit even when using kCLLocationAccuracyBestForNavigation as the CLLocationManager's accuracy. I need it to be centered like Apple Maps as shown bellow. How would I go about doing this? Is there a way to snap MKAnnotation's to roads (or MKPloylines) and update with the CLLocationManager's userLocation?
Posted Last updated
.
Post not yet marked as solved
2 Replies
13k Views
I'm creating an app that uses WKWebView. Whenever a user clicks on a link in that webview, I want the link to open up in safari instead of inside the webview. I'm really new at coding, so please make it as easy as possible. I just need the code I need to add. Here's the code bellow:import UIKit import WebKit class FirstViewController: UIViewController { @IBOutlet var containerView: UIView! = nil var webView: WKWebView? override func loadView() { super.loadView() self.webView = WKWebView() self.view = self.webView! } override func viewDidLoad() { super.viewDidLoad() var url = NSURL(string:"http://www.example.com/") var req = NSURLRequest(url:url as! URL) self.webView!.load(req as URLRequest) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } }I'm using Xcode 8 and Swift 3
Posted Last updated
.
Post not yet marked as solved
1 Replies
488 Views
Is there a way to make use of the Night Mode feature on iPhone 11s and 12s in camera applications using AVFoundation? I've looked all over the internet and cannot find any solutions, I feel like I have to be missing something. If not, do we know if this will ever become available (especially with ProResRAW shipping later this year)?
Posted Last updated
.
Post not yet marked as solved
0 Replies
580 Views
Hello. I am creating an iOS app for my music I have written. I would like to add a feature like Shazam's where my users can see which song of mine is playing. Not playing on the device, but playing in a room via a speaker or something like that. Just like Shazam, only just for my music. I would like to do this all locally, in my app. I've been doing a LOT of research on how to accomplish this for days, now, but to no avail. Basically what I need to happen is, a user records a clip of the song that is playing (like 5-10 seconds, whatever is needed) and that clip will run through all of my song (which is stored locally on the app) and bring up the correct song. I've learned some about audio fingerprinting and such, but I don't exactly understand it. Could someone please help me? Whether it's just leading me to a tutorial (I have yet to find one for Swift and Xcode), or helping me yourself, ANYTHING is appreciated. Thanks so much for taking the time to read this!
Posted Last updated
.
Post not yet marked as solved
2 Replies
398 Views
Ok so I'm wanting to sort an array based off of another array. Ok so that probably sounds pretty confusing so let me explain.Alright so let's make an example of an app about grocery shopping. Ok so I have an array like this: var fruitsArray = [String:Int]()Let's say that the values of the array are [apple:32, banana:45, grape:7, strawberry:23]Ok so first off, I sort this array by the `Int`, descendingly, which gives us [banana:45 apple:32, strawberry:23, grape:7]Ok great. But now I want an array of shopping lists and each element of that array contains an array of food. So let's make a `Struct`... struct List { var name:String = "" var items:[String] = [""] init(name: String, items: [String) { self.name = name self.items = items } }and then an array of `List`... var shoppingLists = [List]()finally, let's add some elements to `shoppingLists`... [List(name: List 1, items: [banana, pizza, watermelon, apple]), List(name: List 2, items: [cookie, water, grape, apple]), List(name: List 3, items: [apple, strawberry, banana, cheese]), List(name: List 4, items: [apple, strawberry, grape, watermelon])]Ok so this is where it gets kinda difficult. I want to sort `shoppingLists` by looking at the `items` array in `shoppingLists` and comparing them with `fruitsArray`. Let me show you what I want the final product would be and then I'll explain why. sortedShoppingList = [List(name: List 3, items: [apple, strawberry, banana, cheese]), List(name: List 4, items: [apple, strawberry, grape, watermelon]), List(name: List 1, items: [banana, pizza, watermelon, apple]), List(name: List 2, items: [cookie, water, grape, apple])]Ok so why in the world is it sorted like this? Let's take it element by element. So List 3 is at the top because it contains 3 elements from fruitsArray. Now you might be saying list 4 also contains 3 elements from `fruitsArray` and yes that's true, but list 3 contains elements from `fruitsArray` that are higher in "ranking". Both list 3 and 4 contain [apple, strawberry] but list 3 contains `banana` while list 4 contains `grape`. `Banana` "outranksks" `grape` therefore making list 3 first. So moving on, List 1 is after list 4 because it contains [apple, banana] which is higher in "rank" than the [apple, grape] in list 2.Alright well, I really hope that wasn't confusing. If you have any questions or need me to clarify, please ask! Thanks so much for reading this and I hope you can help me out.
Posted Last updated
.
Post not yet marked as solved
1 Replies
272 Views
I was wondering if anyone knew of some type of extension or something that translates stringsfor Swift. I know that you can localize strings by using a Localizable.stings file, but I get most of my strings from an API. So, I wouldn't be able to add the strings to the Localizable.stings file because the strings are not hard coded.I'm looking for something where the code would translate the string like Google Translate, or something. Please tell me if you have found anything like this or if you have a solution.
Posted Last updated
.
Post marked as solved
1 Replies
1.5k Views
I'm trying to share a string from my iOS app to my WatchKit-app. I have enabled App-Groupsfor both the iOS app and the WatchKit extension. Then, in my iOS app, I set a variable for the UserDefaults.let defaults = UserDefaults(suiteName: "group.com.jacobcavin.appName")Then in the ViewController, I set defaults to a string from the text of a TextField.defaults?.set(textField.text!, forKey: "KEY")Inside the iOS app, this works perfectly and I can access this and get the right value. But, inside the WatchKit app, I try to get the string.let defaults = UserDefaults(suiteName: "group.com.jacobcavin.appName") let string = defaults?.string(forKey: "KEY")But string returns nil. I've looked through tons of tutorials, and I have made sure that each target has the same group identifier, different Bundle Identifiers, and the entitlement .plist files are correct. Can you please help?
Posted Last updated
.