Questions tagged [swift]

Swift is a general-purpose, open-source programming language developed by Apple Inc. for its platforms and Linux. Use the tag only for questions about language features, or requiring code in Swift. Use the tags [ios], [ipados], [macos], [watch-os], [tvos], [cocoa-touch], and [cocoa] for (language-agnostic) questions about the platforms or frameworks.

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

Vectorisation in Swift

does anyone know how you can vectorise an image (preferably in AR). The image would only consist of basic lines and shapes. I'd like it the vector to overlay the real vision through the camera using ...
0
votes
0answers
8 views

Instantly update frontend with uploaded image

I have an app that does direct messaging similar to instagram and others. Currently when a user enters text it immediately updates the UI. Where I'm having trouble is when a user attempts to send an ...
0
votes
1answer
14 views

How many ways there to write a closure in swift?

Below is a function in swift: func msgFunc() -> String { return "hello, I'm a msgFunc" } How many ways are there to write this function as a closure in swift?
0
votes
1answer
12 views

Swift Double - divide with 2 decimal places

I want it to show 2 decimal places.. e.g. when in put is 3/4 it should show 0.75 however it is showing 0.0 - not giving any errors.. ``` func calculator() { let a = Int(readLine()!)! //...
0
votes
0answers
8 views

how to change the size of a uiimageview appended to a empty array

My swift code uses a button to place imageviews on a uiviewcontroller that parent from a empty array. The problem is I dont know how to effect the size of the invidicual imageview after it is placed ...
0
votes
0answers
12 views

badly formatted UUID fails in Swift but not in Kotlin

In Swift, if one runs this code, it prints "nil" because the UUID is badly formatted. import Foundation let id = "11111111-1111-1111-1111-badbad" print(UUID(uuidString: id)) // prints nil However, ...
0
votes
1answer
20 views

How to set delegate with a tableview that contains a collection view?

So I have a view controller that contains a UISegmentedControl, a tableview with 2 cells, and in those two table view cells I have a collection view in each of them that should display different data ...
0
votes
0answers
8 views

How can I get the head rotation value with ARKit3?

I am using ARKit3. I tried DL the sample code from the following URL. Tracking and Visualizing Faces https://developer.apple.com/documentation/arkit/tracking_and_visualizing_faces I tried to get a ...
0
votes
0answers
5 views

Open iframe video in fullscreen programmatically

I open youtube video using iframe in webview. It shows default control buttons for video including fullscreen button. How can I call function of fullscreen button by myself? For example, I want go to ...
0
votes
0answers
11 views

CollectionView not loading image urls into UIImageView

I'm trying to learn iOS programming so I thought it would be a good idea to emulate instagrams feed. Everyone uses this basic feed and I would like to know how to do it. The basic idea is to have ...
-1
votes
0answers
10 views

Modify the height of viewcontroller iOS 13

now with that way of displaying the view controller, I would like to reduce the height of the view controller, as can be detected in the image in the view controller 2, there are some rectangles, and ...
0
votes
0answers
11 views

How to clear/invalidate ambient cache on iOS app

When I update tilesets on mapbox, changes don't appear in the iOS app unless I re-install it. There is seemingly documentation on this here: https://docs.mapbox.com/ios/api/maps/5.2.0/Classes/...
0
votes
0answers
20 views

Downlaod the other app from server and run inline any native iOS app [closed]

I need to create a child app which need to upload on our own server. I will have another parent app with some functionality. I need to download the server app within our parent app and run the same ...
0
votes
1answer
15 views

A programmatically UISlider not changing width

My swift code is all code no storyboard. My slider sx should change the width of the imagview when the value is changed. That is not happening no change is visible on the imageview. The imageview ...
0
votes
1answer
12 views

Multiple NavigationLink with ForEach

I have a json file that contains an array of school classes name className, when I try to show the classes using Text(className[I]), I get this error: Ambiguous subscript with base type '[String]' ...
0
votes
0answers
9 views

Can I use the Access Token from Firebase Storage Image into my Dynamic Links imageURL?

Im using the access token from firebase storage to preview the image the user is sharing but is not displaying the content. There is any way to re-use that url to show the content from that image. ...
0
votes
0answers
23 views

Preserve state of a view controller from multiple source segues

Scenario I have a mixed project of Objective-C and Swift with both a navigation controller and a tab bar controller. I have a view controller (the only controller that is written in Swift) that has ...
0
votes
0answers
6 views

UIPageViewController with only 1 UIViewController and infinite loop

First at all, I am not using UICollectionView because I need put my Slider inside of a ViewContainer and it's not allowed put repeatable elements in it. As my question title says, I want to get work ...
0
votes
0answers
6 views

Swift - Firestore Document references must have an even number of segments, but

Xcode is giving me this error message: Document references must have an even number of segments, but users/hsiYfWgKz7MVOM77gMPkQYBHYJH2/wishlists has 3' I have no idea why that error occurs ...
0
votes
0answers
6 views

Swift - Error when adding item to macOS Keychain

I'm trying to add an item to the Keychain via SecItemAdd(attributes:, result:). This is my code: public static func addItem(user: String, password: String, server: String, type: String) throws { /...
0
votes
0answers
29 views

I cant get my calculations to print out in another label [duplicate]

I am trying to get the values to calculate the profit and print out the calculated numbers in a label, but it isn't printing it out in the label. When I hover over the values after the app crashed it ...
0
votes
0answers
28 views

Xcode: How can I change the “Default” Tab in a TabBar

I've got an iOS App with a TabBarController in the MainStoryboard. The Tab Bar works fine but I have 5 Tabs, and now the Tab which is selected by default is the first one, but I want the middle one (...
1
vote
0answers
23 views

CoreImage: CIImage write JPG is shifting colors [macOS]

Using CoreImage to filter photos, I have found that saving to JPG file will result in an image that has a subtle but visible blue hue. In this example using a B&W image, the histogram reveals how ...
0
votes
1answer
15 views

reload data from firebase after updating object (row) using alert action

I have a tableView which loads "tasks" in each row from firebase. after clicking on the row (a certain task), i've created an alert that asks if the task is completed. When the user presses "Yes" he ...
0
votes
0answers
8 views

Collection View cell off center when swiping

When I swipe through my collectionView cells they are cut off the page for some reason even tho the first cell is fine. When I get the the last cell then swipe again it bounces and then the last cell ...
0
votes
0answers
18 views

Swift - Update detail view insider container

I have a view controller A that is composed by two containers 1 on the left and 2 on the right. Inside A, I display 1 (a view controller containing a tableView) and 2 (a view controller containing ...
0
votes
1answer
21 views

Swift - Adding labels to stack views programmatically

My goal is to add labels to a stackview in a xib. Everything below works great if the results are being displayed using a view controller. But I don't need to display the view I'm creating. I just ...
-1
votes
2answers
27 views

How to fix an 'Optional nil' on a RevealViewController() Gesture Recognizer?

I'm trying to add a tap and pan gesture recognizer to my RevealViewController() and I'm getting a Value of optional type 'UIGestureRecognizer?' must be unwrapped. How should I unwrap this? // My App ...
0
votes
1answer
20 views

populate array after adding a new child in swift firebase

This is my code to populate my 'Consumables' array (called in my viewDidLoad): //---------------------- POPULATE CONSUMABLE ARRAY --------------------------------// private func ...
0
votes
0answers
32 views

JSON request from swift showing empty array in php

I am trying to make a request to a PHP server from my swift app. For some reason php is showing an empty array as the $_REQUEST variable. I have looked through stack overflow and implemented ...
0
votes
0answers
7 views

popoverPresentationController stretched out

I use a EKEventEditViewController modally for users to edit their events in the app I work for. Since the update for iOS 13, Start and End date fields have stretched out and are difficult to read. (...
0
votes
1answer
18 views

Swift 4 - UIActivityViewController share to Outlook Subject and Title

I am using UIActivityViewController to share text to Outlook, everything is working fine except for two things, one I can't set a subject line and two I cant set a title of that I am sharing, my text ...
-1
votes
1answer
15 views

When implementing infinite scroll (paginating results in UITableView when scrolling to bottom): reloadData or insertRows?

When implementing infinite scroll in a UITableView (loading additional results to the data source when the user scrolls to bottom), should the table be updated by reloadData() or by inserting rows (...
0
votes
0answers
17 views

Wrong with Ssl pinner with swift

i am following with this tutorial, https://infinum.com/the-capsized-eight/266 i showed the certificates with this code: print(ServerTrustPolicy.certificates()) this showed me [<cert(...
0
votes
1answer
9 views

Animate thru various images in Swift - Using customized Load View

I have a customLoader which I would like to call anytime a user logs in. I want to animate thru all seven photos in gifArray. import UIKit class CustomLoader: UIView { static let instance = ...
1
vote
0answers
23 views

Why JSONEncoder works differently with Dictionary of enum keys? [duplicate]

When I use JSONEncoder for structure like this: struct A: Encodable { var items: [String : Int] } let a = A(items: ["a": 1, "b": 2, "c": 3]) I get items property as JSON object as expected: {"a"...
-1
votes
1answer
16 views

Swift - Firestore auto create collection/document

Is there a way to create a collection or document automatically? In my case I already have a collection ("users") and in it are all of the the users. What I would like to achieve is if the user ...
-3
votes
0answers
10 views

Custom Camera View in Twilio Video SDK in Swift

I have tried the testing sample provided by Twilio for video calling but they are using their own builtin camera view. Instead I want to create my own camera view with some frame modifications and ...
-3
votes
1answer
19 views

SWIFT ARKIT detect the hand and nails, and place the object on the nails?

I would like to know how to detect a person’s hand and nails, and then use ARKIT to place an object on her nails. Frankly, I’ve been looking for information about it for several days in Google, I ...
0
votes
3answers
40 views

Why did index go out of range

Hello i'm doing the simple FizzBuzz challenge. I figured out a solution to the problem. But I don't understand why my first attempt went out of range or what is happening behind the scenes. To stop ...
0
votes
1answer
20 views

unit testing a login view controller in ios related queries

i need to perform unit tests for login screen( it has one email textfield, one password textfield and one loginbutton), having a few queries related to it. what i understand of unit testing of ...
0
votes
0answers
8 views

Native ad does not record clicks

I am creating a library for Google Native Ads, and with this I am creating two types of templates one Small and one Medium, both of type GADUnifiedNativeAdView. When I set GADUnifiedNativeAd in the ...
0
votes
0answers
16 views

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.3 compiler

Check several publications with the same compilation error, and it really seems annoying that some libraries do not have support for current versions, well Apple also updates the xcode many times ...
0
votes
1answer
30 views

How to reach variable from viewcontroller in a custom class?

I need to append something to my anchor. I am trying to do this in a function of my class, but i declared this anchor in my viewcontroller. This anchor is not recognized in my class. How do I reach ...
-1
votes
1answer
41 views

Simple question. How to toggle Fullscreen mode in SwiftUI? [edited]

I have searched and couldn't find anything. I honestly can't believe no one else asked this simple as a rock question. My question is so simple in fact, that I don't even see why I would need to ...
1
vote
2answers
27 views

How to prevent back button from dissapearing?

I am creating a doodle page with an "X" as the close/dismiss button. I also have a "clear" button to remove the doodles that have been made. My issue is that when I press clear, even the X button ...
-1
votes
0answers
14 views

Interface Builder View Layout Approach [closed]

I have an app with 4 different metal views (picture a 3D modeling app with one perspective view and 3 orthographic views). I have a limited number of layouts that the user is able to switch between. ...
-3
votes
1answer
45 views

How to add a character from “endIndex” at every three character in Swift?

I have a string like below "12345678" I want to add a separator "," I would like the output to be: "12,345,678" not like to be : "123,345,678" , (because this's from start to count) or not ...
-1
votes
1answer
17 views

How to add UIView corner radius and shadow effect in swift [duplicate]

I have tried many solutions available in over stackoverflow ,but none work. Here is the extension I wrote for dropShadow effect. extension UIView { func dropShadow(color: UIColor, opacity: Float ...
-1
votes
1answer
26 views

Apple Sign In Email Popup

I have to debug the Hide/Show Popup in the Apple SignIn process in the Application, but it comes only once I have deleted the App. Is there any way out to get the Starting Popup options of Hide/Show ...