Skip to content

Instantly share code, notes, and snippets.

View jpm's full-sized avatar

João Prado Maia jpm

  • Hearst Newspapers
  • The Woodlands, TX
View GitHub Profile
@steipete
steipete / TapAndFadeExample.swift
Last active May 19, 2021 00:11
How to build Tap-And-Fade using SwiftUI instead of a hard deselect. The default in SwiftUI is too hard and doesn't feel right.
// Helper to hold the parent VC weakly
class WeakViewControllerHolder: ObservableObject {
weak var vc: UIViewController?
init(_ vc: UIViewController) {
self.vc = vc
}
}
@available(iOS 13.0, *)
@steventroughtonsmith
steventroughtonsmith / PSTLDraggableColorSwatchView.h
Last active May 6, 2021 00:47
Color Swatch view for Mac Catalyst that implements inter-app drag & drop
//
// PSTLDraggableColorSwatchView.h
// Pastel
//
// Created by Steven Troughton-Smith on 06/03/2020.
// Copyright © 2020 Steven Troughton-Smith. All rights reserved.
//
@import UIKit;
@steipete
steipete / PSPDFCatalystPatches.m
Last active October 19, 2019 12:00
Fixes Mac Catalyst: random crash inside [_UIBlurEffectCoreUIImpl _needsUpdateForTransitionFromEnvironment:toEnvironment:usage:] ()
Use this code: (code incomplete, but you get the idea what needs to be done)
// TODO: Stop calling this once 10.15.1 is out!
#if TARGET_OS_UIKITFORMAC
static void PSPDFFixVisualEffectsEnvironment(void) {
static const char *PSPDFVisualEffectsWindowKey;
static const char *PSPDFVisualEffectsSuperviewKey;
let klass = NSClassFromString([NSString stringWithFormat:@"_%@sualEffe%@ironment", @"UIVi", @"ctEnv"]);
@keith
keith / simctl-commands.txt
Last active December 7, 2022 23:27
All the subcommands of `xcrun simctl` (including ones that aren't listed in `simctl help`) LC_SOURCE_VERSION 776.1 (Xcode 13.0 beta 5)
addmedia
addphoto
addvideo
appinfo
boot
bootstatus
clone
create
darwinup
delete
@steipete
steipete / SomeObjCFile.m
Created August 7, 2019 08:57
HACK around FB6940492: Mac Catalyst: Crash when presenting view controllers. Call early.
/**
HACK around FB6940492: Mac Catalyst: Crash when presenting view controllers
'NSRangeException', reason: 'Cannot remove an observer <UINSSceneViewController 0x600003558790> for the key path "view.window.screen.contentLayoutRect" from <UINSSceneViewController 0x600003558790> because it is not registered as an observer.'
0 CoreFoundation 0x00007fff3b20f183 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff71719b64 objc_exception_throw + 48
2 Foundation 0x00007fff3d8ca2aa -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 578
3 Foundation 0x00007fff3d8ca01b -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 74
4 Foundation 0x00007fff3d8e2898 -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:context:] + 190
@steipete
steipete / UIWindow+PSPDFAdditions.h
Last active June 1, 2023 18:24
Mac Catalyst: Get the NSWindow from a UIWindow (Updated for macOS 11 Big Sur, also works with Catalina)
// Don't forget to prefix your category!
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIWindow (PSPDFAdditions)
#if TARGET_OS_UIKITFORMAC
@atomicbird
atomicbird / wwdc2019-online-sessions.md
Last active May 29, 2020 22:59
WWDC 2019 Online-only Sessions

At WWDC 2019 Apple released some videos directly online, with no corresponding live session. This is a list of those videos with links to the video pages.

Some sessions were presented during WWDC but then split into multiple videos when posted online. This list includes the online versions, since they don't appear in the WWDC schedule. For example WWDC included session 711, "Introducing Combine and Advances in Foundation". This was split into two online videos-- 722, "Introducing Combine", and 723, "Advances in Foundation". Both 722 and 723 are included here.

@b3ll
b3ll / CircleLine.swift
Created June 7, 2019 22:20
"unstable" Swift UI Animation in Xcode 11 b1
//
// ContentView.swift
// CircleLine
//
// Created by Adam Bell on 6/5/19.
// Copyright © 2019 Adam Bell. All rights reserved.
//
import SwiftUI
@radazzouz
radazzouz / PDFView.swift
Last active June 7, 2019 17:14
Use PSPDFKit in SwiftUI
import SwiftUI
import PSPDFKitUI
struct PDFView: View {
var url: URL
var configuration: PSPDFConfiguration?
var body: some View {
PDFViewController(url, configuration: configuration)
}
@douglashill
douglashill / KeyboardTableView.swift
Last active March 30, 2023 22:01
A UITableView that allows navigation and selection using a hardware keyboard.
// Douglas Hill, December 2018
// Made for https://douglashill.co/reading-app/
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit
import UIKit
/// A table view that allows navigation and selection using a hardware keyboard.
/// Only supports a single section.
class KeyboardTableView: UITableView {
// These properties may be set or overridden to provide discoverability titles for key commands.