Skip to content

Instantly share code, notes, and snippets.

Max Seelemann macguru

View GitHub Profile
View ChineseFallbackFont.m
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSLog(@"languages: %@", [NSLocale.preferredLanguages componentsJoinedByString: @", "]);
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString: @"暗a"];
@macguru
macguru / UIViewController+Rotation.m
Created Apr 11, 2018
Forcing a rotation on a UIViewController.
View UIViewController+Rotation.m
//
// UIViewController+Rotation.m
// Ulysses
//
// Created by Götz Fabian on 12.10.17.
// Copyright © 2017 Ulysses GmbH & Co. KG. All rights reserved.
//
#import "UIViewController+Rotation.h"
@macguru
macguru / SwizzlingTextView.m
Last active Jan 6, 2018
Swizzling behaviour into TISmartPunctuationController
View SwizzlingTextView.m
@implementation SwizzlingTextView /* Subclass of UITextView */
{
BOOL _swizzled;
}
/* working solution */
- (void)setInputDelegate:(id<UITextInputDelegate>)inputDelegate
{
[super setInputDelegate: inputDelegate];
@macguru
macguru / MXSEventTrackingWindow.h
Created Sep 2, 2016
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.
View MXSEventTrackingWindow.h
//
// 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
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".
View gist:b7a01e3f0e9ae6f350d5
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
Enforce device rotation by using a temporary window and view controller.
View gist:17ee7d47acbb4d4a2258
@interface FixedViewController : UIViewController
@property(nonatomic) NSUInteger supportedInterfaceOrientations;
@end
@implementation FixedViewController
@end
...
- (void)rotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
View SmartInsertCharacterSets.m
+ (NSCharacterSet *)ignoredCharactersBeforeSmartInserts
{
static NSCharacterSet *characterSet;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
/*
Character set taken from AppKit's __getPreSmartSet
*/
NSMutableCharacterSet *mutableSet = [NSMutableCharacterSet characterSetWithCharactersInString:@"([\\\"'#$/-`{<"];
You can’t perform that action at this time.