Blog

How to detect iPhone X through code

I was just playing around with the iPhone X simulator in Xcode, and I realized one of my apps has a view bug. I have a button placed with code (at the bottom of the screen in the middle) that is overlapping the bar that you swipe up to get to the home screen. Is there a way to detect, through code, if the device is an iPhone X, and an iPhone X only, so I can write code to counteract the bug? Maybe by detecting the precise screen width and height, and if so, what are those numbers? Thanks in advance. Any help is appreciated. Powered by WPeMatico »

Override question?

I am trying to create an app similar to the Guided Project: List in “App Development with Swift” with one change.  I would like an opening view controller that segues to the tableview.  I have that set up but when I get to the point in the lesson where it overrides the function viewDidLoad I get an “override can only be specified on class members” error.  That override is already in the viewcontroller.swift file.  Should I delete or change that override in the view controller.swift file?   I hope this is not too vague.  If you need more information let me know.  I am totally new to programming in Swift.   Thanks in advance for any help. Powered by WPeMatico »

Can only pass data between 2 of 3 View Controllers

Hi,   I´m making a simple orderplacement app. This app uses 3 View Controllers: Menu1, Menu2 and Checkout. (Menu2 was recently added, and is the source of the problem) I pass data between Menu VC an Checkout with a Swift file called orderModel. This has been working perfectly for a long time now, but when I added a new VC, Menu2, I got problems. Menu2 won´t pass data to Checkout VC. I have done the 2 menuVC´s identical. Just with different variables.   Menu1: class menu1ViewController: UIViewController { var myOrder = OrderModel() var tomatoes = "Tomatoes" @IBAction func item1(_ sender: UIButton) { myOrder.menu1Tomatoes = tomatoes //Set text to item myOrder.addToMenu1Tomatoes += 1 //Add amou... »

Swift framework wrapping a static library

I now spent 2 days trying to create a Swift framework that includes a static (Objective-C) library, so I guess it is time to ask for help here… My problem: I have a static library created with Objective-C and we need to release a framework that can be used by our customers to use the static library. Creating an Objective-C framework that wraps around the static library is no problem, but as many of our customers use Swift nowadays, it would of course be better if we can create a framework with a cleaned-up Swift interface that wraps around the static library.   What I tried so far (well, the only thing that at least compiled so far): I created a module.modulemap inside of the Objective... »

Differentiate between Homescreen click and Lock Screen click

Hey guys,   I have a bluetooth app that connects to a device. What I want to achieve is this: when a user switches apps or goes to the homescreen, I want to disconnect from the bluetooth device but when a user hits the lock screen, I want the bluetooth connection to be maintained.   I am not super familiar with swift and ios dev so any advice would be great.   Is there a way to determine whether a app is backgrounded due to the user going to the homescreen and when a user simply locks the phone?   Thanks in advance. Powered by WPeMatico »

Skip to toolbar