This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([self.delegate respondsToSelector:@selector(pdfViewController:didDisplayDocument:)]) { | |
[self.delegate pdfViewController:self didDisplayDocument:self.document]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// checks if already in current queue, prevents deadlock | |
void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_block_t block) { | |
if (dispatch_get_current_queue() == queue) { | |
block(); | |
}else { | |
dispatch_sync(queue, block); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)animateImageView:(UIImageView *)imageView newImage:(UIImage *)image { | |
// build animation block | |
CATransition *transition = [CATransition animation]; | |
transition.duration = 0.25f; | |
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
transition.type = kCATransitionFade; | |
[imageView.layer addAnimation:transition forKey:@"image"]; | |
// set new image | |
imageView.image = image; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL PSIsCrappyDevice(void) { | |
static BOOL isCrappyDevice = YES; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
BOOL isSimulator = NO; | |
BOOL isIPad2 = (PSIsIpad() && [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]); | |
BOOL hasRetina = [[UIScreen mainScreen] scale] > 1.f; | |
// enable animations on simulator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create basic UI | |
Titanium.UI.setBackgroundColor('#000'); | |
var tabGroup = Titanium.UI.createTabGroup(); | |
var win1 = Titanium.UI.createWindow({ | |
title:'PSPDFKit', | |
backgroundColor:'#fff' | |
}); | |
var tab1 = Titanium.UI.createTab({ | |
title:'PSPDFKit', | |
window:win1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)dealloc { | |
webView_.delegate = nil; // delegate is self here, so first set to nil before call stopLoading. | |
[webView_ stopLoading]; | |
// UIWebView must be released in the main thread, or we get: | |
// Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now... | |
// This is less evil than the proposed http://stackoverflow.com/questions/945082/uiwebview-in-multithread-viewcontroller | |
// Calling removeFromSuperview in a dealloc is ugly and evil, but else UIView has a strong reference to UIWebView and our main-release call would be irrelevant. | |
if (![NSThread isMainThread]) { | |
[webView_ performSelectorOnMainThread:@selector(removeFromSuperview) withObject:nil waitUntilDone:YES]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PSPDFSetLocalizationDictionary(@{@"en" : | |
@{@"Go to %@" : @"Browse %@", | |
@"%d of %d" : @"Page %d of %d", | |
}}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enable to see memory usage (don't enable in production code) | |
kPSPDFKitDebugMemory = YES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ARC is compatible with iOS 4.0 upwards, but you need at least Xcode 4.2 with Clang LLVM 3.0 to compile it. | |
#if !defined(__clang__) || __clang_major__ < 3 || !__has_feature(objc_arc) | |
#error This project must be compiled with ARC (Xcode 4.2+ with LLVM 3.0 and above) | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/xattr.h> | |
/// Set a flag that the files shouldn't be backuped to iCloud. | |
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath { | |
u_int8_t b = 1; | |
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0); | |
} | |
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available. | |
+ (NSString *)legacyStoragePath { |