Tag: swift

Warning: Attempt to present <GuessMeFinal> on <GuessMeFinal.ViewController> whose view is not in the window hierarchy -Swift

Okay..here’s the problem. When I click the [Play] button in the main menu, it should go to the corresponding ViewController according to this code: @IBAction func playButton(sender: AnyObject) { if rightCounter <= 4 { if let Level1 = self.storyboard!.instantiateViewControllerWithIdentifier(“Level1”) as? Level1 { self.presentViewController(Level1, animated: true, completion: nil) } } if rightCounter >= 5 && rightCounter […]

How can i disable in a Xcode project that a keyboard appears when i touch in a TextField?

Im a bit new in creating a xcode projects, so i have a program that i need to press the TextField to insert some values, but I don’t want to do that with the native keyboard but only with the buttons that I will create, like a calculator. I already explore some definitions and i […]

NSTimer: floating point value can not be converted to UInt8 because it is greater than UInt8.max

My code returns the error: fatal error: floating point value can not be converted to UInt8 because it is greater than UInt8.max. The code is being called when a button is pressed (in a different swift file) but I know that the problem wasn’t with calling the function so I didn’t include it. code: //starts […]

Draw a line that can stretch like the Xcode assistant editor in Swift

When it comes to drawing lines in Swift, most solutions out there are to override the drawRect function in a UIView, but I’m looking for a more dynamic way to draw a line. I have a button, and I want to be able to drag from this button to the next. While dragging, I would […]

Downcast from UITabBarItem? to UITabBarItem only unwraps optionals; did you mean to use '!'

My code was working well in Xcode 6. But, after updating to Xcode 7 I got nearly 20 errors and 50 warnings.This might be some syntax change in Swift 2 Solved all those but can’t figure out this one : Downcast from UITabBarItem? to UITabBarItem only unwraps optionals; did you mean to use ‘!’ let […]

iOS 8 Self Sizing Cells – Allow Zero Height

I am using the self sizing cell feature and it works well until I want to hide a cell completely. I moved away from heightForRowAtIndexPath for this and I setup the following: override func viewDidLoad() { self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.estimatedRowHeight = 0 } However when I have no text for a tableviewcell to render I […]

Swift Continuous Rotation Animation not so continuous

Here is my code. Intent is to continuously rotate the UIImageView named swirls[l]. However, there is a small pause between every rotation start/end. I have gone through every single animation tutorial but cant figure out what the mistake is? let fullRotation = CGFloat(M_PI * 2) let duration = 2.0 let delay = 0.0 let options […]

UI Local Notification – Background Reschedule

I’m learning to develop application for ios with swift, and I’m one doubts, already googled and i not found. I’m creating a to-do list app, and was wondering if there is a way to reschedule a notification when it appears to the user For example the user registers a task every two hours, then the […]

In swift, can a function be a type?

While researching XCTAssert methods by pressing command+click, it looks like they underlying method is a function that has a type (a generic type referred to as T, that conforms to the Equatable protocol). Am I saying this correctly, and if so how do functions comform to protocols? Are functions types? public func XCTAssertEqual<T : Equatable>(_ […]

Passing Dictionary to Watch

I’m trying to pass data from iPhone -> Watch via Watch Connectivity using background transfer via Application Context method. iPhone TableViewController private func configureWCSession() { session?.delegate = self; session?.activateSession() print(“Configured WC Session”) } func getParsePassData () { let gmtTime = NSDate() // Query Parse let query = PFQuery(className: “data”) query.whereKey(“dateGame”, greaterThanOrEqualTo: gmtTime) query.findObjectsInBackgroundWithBlock { (objects:[AnyObject]?, […]