Questions tagged [swift]

86288 questions
1

votes
2

answer
3.1k

Views

Custom PageControl image - Swift

I am trying to set an image for UIPageControl dots. I need to change the default dots, instead of that I need an image. I used the below code self.pageCtrl.currentPageIndicatorTintColor = UIColor.init(patternImage: UIImage(named: 'Page Indicator_Selected')!) self.pageCtrl.pageIndicatorTintColor = UI...
Vineesh TP
1

votes
1

answer
527

Views

filter objects with two nested levels in a query with Realm

I have a model like this: class CalendarEvent: Object, Mappable { dynamic var exId = '' @objc dynamic var title:String = '' @objc dynamic var desc:String = '' dynamic var fullDate = Date() dynamic var date = '' dynamic var time = '' dynamic var location = '' dynamic var subcategory:Subcategory? dyna...
1

votes
3

answer
416

Views

Create a UICollectionView with a reversed flow layout

I want to create a view that resembles a chat view, where the newest message appears at the bottom of the screen. I would like the UICollectionViewCells to be 'pinned' to the bottom of the screen - the opposite of what the default flow layout does. How can I do this? I've got this code from another...
Tometoyou
1

votes
1

answer
1.3k

Views

Swift Query Into Firebase Firestore Nested Array

I have nested data that I'd like to display in a tableView. My data is structured like so... /users /userid name: 'John' age: 23 /likedPosts 0:post1 1:post2 For the tableview I'd like to display these posts (which have their own collection of data). In order to do that I need to... 1) Get the coun...
pmanning
-1

votes
3

answer
24

Views

How to convert Array of string to Array of URL?

Need to convert array of string value to array of URL. Some one help me to convert the String array to URL array in swift.
Siva N
1

votes
2

answer
14

Views

UIView shadow not visible

I have a UIView called containerView. Upon creating the UIView & Adding it to the main view, I'm trying to add a little shadow. My code: let containerView = UIView() let bg_clear = UIColor(hexString: '#34495E') containerView.backgroundColor = bg_clear containerView.layer.cornerRadius = 15 containe...
average_student
0

votes
2

answer
13

Views

CompactMap to filter objects that have nil properties

How do I filter out possible nil values in properties with a compactMap so I don't have to forecast a nil property to return the object. Currently I have let objects: [Object] = anotherObject.array.compactMap ({ return Object(property: $0.property!) }) What I would like is some guard staetment or op...
user1898829
0

votes
0

answer
3

Views

Is markup formatting just for Swift playgrounds?

In swift file, I don’t see editor _ show rendered markup button. For example. //: - Experiment: //: Modify the anyCommonElements(_:_:) function to make a function that returns an array of the elements that any two sequences have in common. //: How can I show this in rendered markup mode in swift f...
John
2

votes
0

answer
9

Views

Update Facebook SDK issue

I use Facebook SDK login feature. In console written 'Your Facebook SDK is out of date. We recommend upgrading to the latest Version 4.37.0, to ensure your app's performance is not affected and to take advantage of our newest features!' I updated SDK pods to 4.4.1, but this warning still there. Any...
Artyom Vlasenko
3

votes
1

answer
71

Views

iOS Resuming HLS download and deleting partially downloaded file

I am implementing HLS streaming as per Apple Docs But the problem that I am facing is for resuming the download when the user kills the app. If a download is in progress and say its 50% done and the user kills the app or app is killed by the system due to any reason and when the app is alive again...
Girish Nair
1

votes
1

answer
407

Views

ARKit floating planes

Sometimes ARKit creates plane over existing one. It doesn't merge them. I am testing ARKit with iPhone 7 in closed space. Object placed on that plane appears to float in space. This scenario doesn't happen often, and I can't reproduce it all the time. Can someone tell me how to prevent overlapping a...
Paki
1

votes
1

answer
476

Views

Is there a way to convert CMSampleBuffer into CVImageBuffer?

I am using a framework (MoodMe) to detect faces on iPhone camera and I need to pass a image or frame to MoodMe instance. I have converted the camera output into a UIImage but the framework does not detect any face. (I think it) So I want to pass to my buffer to framework, it is asking me for a CVIm...
Igor Custodio
1

votes
1

answer
628

Views

iOS - Trigger outgoing VOIP Call on clicking the caller in the native iOS Recent call table view

I have implemented the CallKit for my App to trigger/receive both Audio and Video Call within our App by using WebRTC. Which is working seamlessly without any problem. As I see there are 3 ways to trigger a call from Call Kit. Performing an interaction within the app Opening a link with a supported...
i70ro
1

votes
1

answer
1.2k

Views

Copy file with swift

I am copying a file database with this code try fileManager.copyItem(atPath: storeURL.path, toPath: storeCopyURL.path) I can see that a new sqlite database is created later, when I try to use this function try! sharedInstance.managedObjectStore.addSQLitePersistentStore(atPath: storeURL.path, fromSe...
j.doe
1

votes
1

answer
566

Views

Swift protocol conformance requirements for subtypes [duplicate]

This question already has an answer here: Why can't a get-only property requirement in a protocol be satisfied by a property which conforms? 1 answer (if someone can suggest a better title, please do) The following code does not compile with an error Type 'ObserverClass' does not conform to protoco...
user1244109
1

votes
1

answer
185

Views

Stop Sound playing on Node in SceneKit

I have the following code for a gesture recogniser that plays a horn, when tapped, and stops when it is released: @objc func didPressHorn(_ sender: UILongPressGestureRecognizer) { let tapLocation = sender.location(in: sceneView) if sender.state == .began { if (wasNodeTapped(node: hornNode!, tapLocat...
Pascal
1

votes
1

answer
111

Views

Why does resizing a label require a delay to update as expected when coming from NotificationCenter?

I'm in the process of adding dynamic type to my app and I'm trying to update the frame of a programmatically created UILabel when the UIContentSizeCategoryDidChangeNotification notification is fired through the following code: private func configureNotificationCenter() { NotificationCenter.default.a...
elfanek
1

votes
1

answer
260

Views

Firebase deploy get ID with onCreate for push notifications

I'm creating an iOS app and sending notifications. I'm trying to get an id from Firebase but the code below doesn't work. exports.pushNotifications = functions.database.ref('/message/{messageId}') .onCreate((snap, context) => { var messageId = event.params.uid; . . . I tried this code from the docum...
coonie
1

votes
1

answer
124

Views

UITests failing when run in group but succeed when run independently

I'm currently working on a project with many asynchronous code and I'm writing the UITests for this project. During the development I run them one by one but never in a group. So I thought the tests are succeeding. But when testing them all together most of them are failing. I implemented the setup...
Tom Kuschka
1

votes
1

answer
499

Views

Swift - Is There A “Dictionary With Duplicate Keys” Workaround?

Currently I am working with alamofire to send post requests to a certain site. In the paramaters of the post request, there is a duplicate key entry that is required to send the post request, but when I am making the dictionary and enter both keys as string literals, I receive the nasty 'Duplicate K...
David K
1

votes
1

answer
1.3k

Views

What is the proper way to change the name of a ViewController class in Swift?

When I change my ViewController class name after it's been created and assigned to a view controller in storyboards I run into problems with the IBOutlets of that view controller, and Xcode does not automatically show the corresponding class in the assistant editor when I click the scene. I've chang...
Austin Berenyi
0

votes
1

answer
25

Views

Custom views are not showing up properly

I am trying to show 3 custom views in an iOS screen but only one of them is showing up. 2nd one started showing up a bit in improper way after putting alot of constraints and third one is completely not showing up.For test I am calling the same view three times. See the code. I have just started doi...
moniovic
0

votes
2

answer
19

Views

Accessing rightBarButton function from another ViewController in Swift

I'm trying to access the rightBarButton function for showing cart from an another ViewController, although I can call that function but it won't display any image i.e cart image Below code show how am i calling this function. override func viewDidLoad() { super.viewDidLoad() // Adding Right Bar Butt...
ExecutionerAxe
0

votes
0

answer
12

Views

error values Optional(Error Domain=kCLErrorDomain Code=8 “(null)”)

I am using mapkit to show locations, for search location, when the user type the location that location showed in mapkit. implemented custom search with autofilled locations, all are working fine. but when I click the some locations name in tableview it is showing Error Domain=kCLErrorDomain Code=8...
naga
0

votes
2

answer
25

Views

How to get rawValue of enum using there sub function?

Enum that is defined like below. enum PurchaseTimeType: Int,CaseIterable { case ASAP, ThisMonth, NextMonth func id() -> Int { switch self { case .ASAP: return 1 case .ThisMonth: return 2 case .NextMonth: return 3 } } func title() -> String { switch self { case .ASAP: return 'ASAP' case .ThisMonth: r...
PinkeshGjr
0

votes
0

answer
4

Views

TouchUpInside without LinkAttribute in ASTextNode

I have one text (ASTextNode) let contentNode = ASTextNode() contentNode.maximumNumberOfLines = 7 contentNode.truncationMode = .byTruncatingTail contentNode.isUserInteractionEnabled = true contentNode.delegate = self and in contentNode have link I setup touchUpInSide for contentNode contentNode.addTa...
0

votes
0

answer
5

Views

How to retrieve an environment texture (MTLTexture) cubeMap and change to Spherical Harmonics

I would like to save the auto-generated environment texture from an ARWorldTrackingConfiguration, and then load that same texture later into a different tracking configuration to be added to a model. How is this done? I have looked through everything I could find online and looked through Apple's do...
A.M.
1

votes
3

answer
1.1k

Views

Swift 4 back button doesn't appear

I have problem... i have two ViewControllers and i use this code to pass from 1st VC to 2nd let storyBoard: UIStoryboard = UIStoryboard(name: 'Main', bundle: nil) let newViewController = storyBoard.instantiateViewController(withIdentifier: 'EVSignInViewController') as! EVSignInViewController self.pr...
George Heints
1

votes
1

answer
916

Views

How to convert TimeInterval to CMTime in Swift 4?

I can’t seem to figure out how to convert TimeInterval to CMTime. Does it need more than just a simple conversion method?
Colin FB
1

votes
1

answer
140

Views

Make circle with slice cut out? iOS Swift 4

I'm trying to create a very simple colored circle inside a UIView with a slice cut out or in a different color, something like this: I expected that this would be very simple and would only require a few lines of code since CAShapeLayer allows you to create all sorts of shapes. However, it seems tha...
Freddy Benson
1

votes
1

answer
368

Views

setting scnnode presentation position

I want to set the transform of both a given scn:SCNNode and its current presentation node, to a new value. However, I'm having trouble setting the presentation node. I've tried four ways: Set presentation node's transform: scn.position = newVal scn.presentation.position = newVal scn.pre...
Allen King
1

votes
2

answer
54

Views

In Xcode, how would you go about having view controllers which are only accessible to the user if they perform a certain action in the app?

The app I am making has multiple pages which the user swipes between. I need the user to be able to press a button and that create a new page in the app, and then also for the user to be able to delete that page of the app. Is there a way to generate/delete a view controller while the app is in use?...
Peter Ruppert
1

votes
1

answer
270

Views

How to remove bottom border of navigation bar with large title?

For navigation bar with small title, we could add these 2 lines in viewDidLoad to make the border disappear: navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) navigationController?.navigationBar.shadowImage = UIImage() However, when I do this for navigatio...
Kelvin Lui
1

votes
1

answer
228

Views

3D Touch: registerForPreviewing in UICollectionViewCell

Here the scenario is, UICollectionView is in UITableViewCell and UITableView is on UIViewController, now I have to use UILongPressGestureRecognizerif 3D Touch is not available I need to register it in UICollectionView Cell, UILongPressGestureRecognizer is working perfectly, but I'm not able to regis...
Abhishek Mitra
1

votes
2

answer
51

Views

How do you satisfy the 'lineOrigins' argument in CTFrameGetLineOrigins() in Swift? [duplicate]

This question already has an answer here: Issue with CoreText CTFrameGetLineOrigins in Swift 1 answer I'm trying to figure out CTFrameGetLineOrigins from here: CTFrameGetLineOrigins Got Incorrect Origins, and trying to convert the ObjC to Swift. Obj-C: CFArrayRef lines = CTFrameGetLines(frame); siz...
Kevin Wang
1

votes
2

answer
415

Views

Black screen is coming below the presented view controller

I am trying to present a view controller modally. It is like a pop up view controller. I am using animateTransition method to animate the transition. This is my code: extension PopUpViewController: UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning { func transitionDuratio...
Sudhanshu Gupta
1

votes
1

answer
281

Views

IOS Rxswift use Kingfisher to prefetch cell Image

I'm trying to implement Kingfisher prefetch feature inside an Rxswift project. The problem is with these 2 function collectionView.rx.prefetchItems collectionView.rx.cancelPrefetchingForItems The instruction at Kingfisher github is quite short override func viewDidLoad() { super.viewDidLoad() colle...
Lê Khánh Vinh
1

votes
2

answer
887

Views

Swift - “Expected to decode Array<Any> but found a dictionary instead.”

I am having a lot of trouble trying to decode this JSON with Swift 4.2: { token = a3253e6ade9b5c7fd99673938bb28b3e; user = { 'about_me' = Admin; address = ''; 'banner_path' = 'http://members.sharjahcd.ae/images/000/000/008/1540737652129.jpg?1541043871'; company = ''; description = ''; email = 'a...
Vignesh
1

votes
2

answer
79

Views

Closure recursion and retain cycles

My closure retains itself. It causes capturing all other objects inside. I can pass such objects using weak reference, but it doesn't solve the problem of retain cycle. What's the right way to do recursion with closures without retain cycles? class Foo { var s = 'Bar' deinit { print('deinit') // Won...
Artyom Devyatov
1

votes
2

answer
142

Views

Dependency injection in UIViewControllers iOS swift

First I checked this post and it wasn't useful I want to apply dependency injection on navigation from a controller to another, let's say I have controller A : import UIKit class A: UIViewController { } and a controller B : import UIKit class B: UIViewController { var name : String! } I'm naviga...
MhmdRizk

View additional questions