Skip to content

Instantly share code, notes, and snippets.

View steipete's full-sized avatar

Peter Steinberger steipete

View GitHub Profile
@jverkoey
jverkoey / shouldAutorotate_nonintrusive.m
Last active August 29, 2015 13:57
Implementing UINavigationController/UITabBarController support for shouldAutorotate without subclassing or extending.
// Add this to your app delegate.
// Neither `UINavigationController` nor `UITabBarController` have the slightest decency to ask their
// visible view controller whether IT would like to rotate and just go on and do whatever the hell
// they please. This'll show 'em.
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
UIViewController* topViewController = window.rootViewController;
do {
// Navigate modal controllers.
@matthiasplappert
matthiasplappert / gist:9493050
Last active August 29, 2015 13:57
QuickLook Debugging for `UIView`
@interface UIView (MPAdditions)
@end
@implementation UIView (MPAdditions)
- (id)debugQuickLookObject {
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) {
return nil;
}

When dismissing a view controller on top of a view controller with UIModalPresentationPageSheet or UIModalPresentationFormSheet, the presenting view controllers frame and transform can get miscomputed on iOS 7. Here is a fix I used in SPLSpeechBubblePopoverController:

@implementation UIViewController (SPLSpeechBubblePopoverControllerHack)

+ (void)load
{
    class_swizzleSelector(self, @selector(dismissViewControllerAnimated:completion:), @selector(__SPLSpeechBubblePopoverControllerDismissViewControllerAnimated:completion:));
}
@jbafford
jbafford / gist:d91ac15cf79a22e70f65
Created August 4, 2014 21:03
List OSX codesign versions for installed apps
find /Applications ~/Applications -maxdepth 3 -name "*.app" | while read a ; do echo; echo -n "$a ___ "; codesign -vd "${a}" 2>&1 | awk '/version/ {print $3}'; done | awk -F'___' '{print $2 " " $1}' | sort -u
@ognian-
ognian- / android_ANRDetector
Created September 12, 2014 18:46
Android: detect long blocks on the main thread, and log a stack trace. Construct the object on the main thread and check the log output. Pass the threshold to trigger a stack dump in milliseconds.
import android.os.Looper;
import android.os.MessageQueue;
import android.util.Log;
import android.util.Printer;
public class ANRDetector {
public static final String TAG = "ANRDetector";
private final Looper looper;
private final MessageQueue queue;
@implementation NSArray (BadThirdPartyImplementation)
- (id)firstObject
{
return self[0];
}
@end
- (instancetype)initWithCoder:(NSCoder *)coder {
if ((self = [self init])) {
NSDictionary *pointValue = [coder decodeObjectForKey:@"point"];
CGPointMakeWithDictionaryRepresentation((__bridge CFDictionaryRef)pointValue, &_point);
_number = [coder decodeDoubleForKey:@"number"];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder {
anonymous
anonymous / gist:18c0d9750840635d25aa
Created July 22, 2015 13:34
vImage Data
CGDataProviderRef topProvider = CGImageGetDataProvider(someCGImageRef);
CFDataRef topBitmapData = CGDataProviderCopyData(topProvider);
size_t width = CGImageGetWidth(someCGImageRef);
size_t height = CGImageGetHeight(someCGImageRef);
size_t bytesPerRow = CGImageGetBytesPerRow(someCGImageRef);
vImage_Buffer topBuffer = {
.data = (void *)CFDataGetBytePtr(topBitmapData),
.width = width,
@kcharwood
kcharwood / UITestExtension.swift
Last active August 29, 2015 14:26
With Xcode 7 Beta 4, Apple gave us a way to wait asynchronously during UI tests. This gist lets you wait on an Activity Indicator to finish.
import Foundation
import XCTest
extension XCTestCase {
func waitForActivityIndicatorToStartAndFinishSpinning(activityIndicatorElement: XCUIElement, timeout: NSTimeInterval = 30.0) {
let inProgressPredicate = NSPredicate(format: "label = 'In progress'")
self.expectationForPredicate(inProgressPredicate, evaluatedWithObject: activityIndicatorElement, handler: nil)
self.waitForExpectationsWithTimeout(timeout, handler: nil)
@0xced
0xced / README.md
Created April 5, 2010 22:31
ABGetMe implementation for iOS