What does the text inside parentheses in @interface and @implementation directives mean?

Those are called Categories and allow you to add further functionality to your classes. A category allows you to add methods to an existing class—even to one for which you do not have the source. Categories are a powerful feature that allows you to extend the functionality of existing classes without subclassing. Using categories, you … Read more

In Call Status Bar (Unable to Satisfy Constraints)

iOS 9.2.1, Xcode 7.2.1, ARC enabled UPDATE 3/25/2016: Conflict still exists in Xcode 7.3, iOS 9.3. Summary: In the window hierarchy for your application there are various windows that get added onto the application window. In my case, this was the UITextEffectsWindow and the UIRemoteKeyboardWindow. These windows come with preconfigured constraints. It seems there is … Read more

How to maintain presenting view controller’s orientation when dismissing modal view controller?

– (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if ([self.window.rootViewController.presentedViewController isKindOfClass: [SecondViewController class]]) { SecondViewController *secondController = (SecondViewController *) self.window.rootViewController.presentedViewController; if (secondController.isPresented) return UIInterfaceOrientationMaskAll; else return UIInterfaceOrientationMaskPortrait; } else return UIInterfaceOrientationMaskPortrait; } And for Swift func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow) -> Int { if self.window?.rootViewController?.presentedViewController? is SecondViewController { let secondController = self.window!.rootViewController.presentedViewController as SecondViewController if secondController.isPresented … Read more

How to use presentModalViewController to create a transparent view

After iOS 3.2 there is a method to do this without any “tricks” – see the documentation for the modalPresentationStyle property. You have a rootViewController which will present the viewController. So here’s the code to success: viewController.view.backgroundColor = [UIColor clearColor]; rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext; [rootViewController presentModalViewController:viewController animated:YES]; With this method the viewController’s background will be transparent … Read more

How do I make a custom initializer for a UIViewController subclass in Swift?

class ViewController: UIViewController { var imageURL: NSURL? // this is a convenient way to create this view controller without a imageURL convenience init() { self.init(imageURL: nil) } init(imageURL: NSURL?) { self.imageURL = imageURL super.init(nibName: nil, bundle: nil) } // if this view controller is loaded from a storyboard, imageURL will be nil required init?(coder aDecoder: … Read more

Add a UIView above all, even the navigation bar

You can do that by adding your view directly to the keyWindow: UIView *myView = /* <- Your custom view */; UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow; [currentWindow addSubview:myView]; UPDATE — For Swift 4.1 and above let currentWindow: UIWindow? = UIApplication.shared.keyWindow currentWindow?.addSubview(myView) UPDATE for iOS13 and above keyWindow is deprecated. You should use the following: UIApplication.shared.windows.first(where: … Read more

iOS 9 Segue Causes App To Freeze (no crash or error thrown)

So basically the segue was freezing because of the UITextView‘s I was using in the destinationViewController. The following fixed the issue: Delete all UITextView‘s Add new UITextView’s you must leave the default lorem imposed text and change this programmatically in the viewDidLoad() This was the fix for me, and from the research I have done … Read more

How do I present a UIViewController from SKScene?

You’re creating a new view controller but never presenting it: SpriteViewController *viewController = [SpriteViewController alloc]; I’m assuming that SpriteViewController is what presents your SpriteMyScene, and you’d like to hand control back to the presenting SpriteViewController. You need to keep a reference to SpriteViewController in your SpriteMyScene subclass, and then access that reference when you call … Read more