Skip to content

Instantly share code, notes, and snippets.

View macguru's full-sized avatar

Max Seelemann macguru

View GitHub Profile
@macguru
macguru / SwizzlingTextView.m
Last active January 6, 2018 15:55
Swizzling behaviour into TISmartPunctuationController
@implementation SwizzlingTextView /* Subclass of UITextView */
{
BOOL _swizzled;
}
/* working solution */
- (void)setInputDelegate:(id<UITextInputDelegate>)inputDelegate
{
[super setInputDelegate: inputDelegate];
@macguru
macguru / MXSEventTrackingWindow.h
Created September 2, 2016 10:47
Tell if a user interaction is currently happening though a touch event in a view's window or something else – like an external keyboard or interaction in a different window (keyboard window). Example use: check if selection change was through touch or external keyboard.
//
// MXSEventTrackingWindow.h
//
// Created by Max Seelemann on 01.09.16.
// Copyright © 2016 The Soulmen. All rights reserved.
//
/*!
@abstract Special window class used for advanced event processing.
*/
@macguru
macguru / gist:b7a01e3f0e9ae6f350d5
Last active May 10, 2020 20:58
Interface sizes a regular Universal app must support with iOS 11 when supporting all devices. Starts with iPhone 5 and goes up to iPad Pro 12.9".
COMPACT WIDTH (stacked view)
- 320 x 568 pt
-> iPhone 5, 5s
- 320 x 768 pt
-> iPad 9.7" Split Landscape 2/3 right
- 320 x 834 pt
-> iPad 10.5" Split Landscape 2/3 right
- 320 x 1024 pt
-> iPad 9.7" Split Portrait right
@macguru
macguru / gist:17ee7d47acbb4d4a2258
Created May 28, 2014 13:33
Enforce device rotation by using a temporary window and view controller.
@interface FixedViewController : UIViewController
@property(nonatomic) NSUInteger supportedInterfaceOrientations;
@end
@implementation FixedViewController
@end
...
- (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
+ (NSCharacterSet *)ignoredCharactersBeforeSmartInserts
{
static NSCharacterSet *characterSet;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
/*
Character set taken from AppKit's __getPreSmartSet
*/
NSMutableCharacterSet *mutableSet = [NSMutableCharacterSet characterSetWithCharactersInString:@"([\\\"'#$/-`{<"];