Swift 3 tableView does not update on reloadData ()

I am building a master detail app. I have a sections view controller (VC) which is a child of master VC. Clicking on rows in the sections VC brings up different detail VCs where users complete required information. Once the information in a detail VC

How to set Auto-Layout-Constraints for ImageView in ScrollView?

I want to display a zoomable image in a ScrollView. Also, the ViewController should contain a toolbar. I have set the following constraints: Toolbar: Left: 0, Right: 0, Bottom Layout Guide: 0 ScrollView: Top Layout Guide: 0, Left: 0, Right: 0, Toolba

Validation by e-mail is incorrect according to Regex

I am using email validation into my project which method is like below //MARK: isValidEmailID func isValidEmail(testStr:String) -> Bool { print("validate emilId: \(testStr)") let emailRegEx = "^(?:(?:(?:(?: )*(?:(?:(?:\\t| )*\\r\\n)?(?:\

Creating a circular progress bar around an image in swift

I am trying to create a circular progress bar around an image as shown in the screenshot below. So far I have managed to create a round image with a green border using the code below: self.image.layer.cornerRadius = self.image.frame.size.width / 2 se

How to create a UIImageView extension rounded by itself

I've been experiencing an annoying problem recently. Assume I want to use an image in multiple places across my application, and everywhere it has to be rounded so as to be a circle. Because I want my code to be clean, I think that this functionality

Sort an array in a hierarchical structure for UITableView

I have an array of customer objects that each have an ID for themselves, and a parent ID. Example: [ Customer(id: 1, parentId: nil), Customer(id: 2, parentId: 3), Customer(id: 3, parentId: 1), Customer(id: 4, parentId: 1) ] My goal is to rearrange th

How to convert Base64 string to NSData?

I have an iOS application (written in Swift) that retrieves data from a wcf service in JSON format. One of the data is an image stored as a base64string. However, I was not able to convert the base64string to NSData. My main purpose is to convert bas

How to wait for a function call to end with Swift

This question already has an answer here: Returning data from async call in Swift function 4 answers My question is simple but after many research and tests I do not succeed to wait for a function end before continuing the flow. Example : print("Befo

Physical problem: the ball bounces too high

I am working on game where a ball bounces and hits a platform and then bounces right back. Ideally the ball should bounce to exactly the height that it started at. However, in my game the ball slowly keeps bouncing higher and higher. I've looked at t

Fast variable initialization via a type instance

I want to declare some variables at the beginning of a class and have their values be modified later and elsewhere. I'd rather not assign an initial garbage value to these to keep things concise. Can I declare variables of basic types by declaring th

Is there a way for VoiceOver to read a custom label?

I'd like to have my QR code scanning app inform the user when it finds a QR code. For sighted users, this works using a label at the bottom that updates to notify the user. However, a blind user would have to tap on that label again to have it read b

How to set the default language in iOS 7?

I have an app with 3 langages, Base, French and English. The app displays in French when I set the iOS7 langage to Italian Why is the app considering French as the default langage ? How to change that to English ?Access your target by clicking on you

Do I need layoutIfNeeded () or kCAGravityResize for my CALayer?

I have successfully started a session on a sublayer but the video looks like this. Do I need to add self.view.layoutIfNeeded() somewhere? If so where can I put it? I've put it in a few different areas but no go. Should I be using something called kCA

Cell change is applied to multiple cells

When a user clicks on a button inside the cell of my tableView, I want it to change multiple properties of the cell. I assign a the indexPath.row value as the tag value to each cell in a different class. Here's my code: @IBAction func upvote(sender:

Change the text color of the swift placeholder

How do I change the placeholder text color of a UITextField through Swift? I can't seem to access the placeholder attribute. ThanksYou can set the placeholder text using an Attributed string. Set color to attributes Property. textField.attributedPlac

Make a triangle in a UIView with a CGRect frame

HI I am making a game and need a spike at the bottom which I have decided to do via a UIView and collisions. I am coding in swift. I currently have a square: //Object Setup let square = UIView(frame: CGRect(x:100, y:100, width: 100, height: 100)) squ

Cocoa NSTextField changes the color of the placeholder

I try to change the placeholder text color. This code doesn't work: let color = NSColor.redColor() let attrs = [NSForegroundColorAttributeName: color] let placeHolderStr = NSAttributedString(string: "My placeholder", attributes: attrs) myTextFie

Convert CGFloat to CFloat in Swift

I'm simply trying to round the CGFloat return value of CGRectGetWidth. override func layoutSubviews() { let roundedWidth = roundf(CGRectGetWidth(self.bounds)) ... } The compiler won't let me, giving the error: 'NSNumber' is not a subtype of 'CFloat'.