Skip to content

Commit 62d2024

Browse files
committed
Update for PSPDFKit 5.1 for iOS. Also removes interface orientation lock.
1 parent 884fbd9 commit 62d2024

File tree

6 files changed

+15
-40
lines changed

6 files changed

+15
-40
lines changed

Classes/ComPspdfkitModule.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ static BOOL PSTReplaceMethodWithBlock(Class c, SEL origSEL, SEL newSEL, id block
5454
return YES;
5555
}
5656

57-
@interface TIPSPDFViewControllerProxy (PSPDFInternal)
58-
@property(atomic, assign) UIInterfaceOrientation lockedInterfaceOrientationValue;
59-
@end
60-
6157
@interface TiRootViewController (PSPDFInternal)
6258
- (void)refreshOrientationWithDuration:(NSTimeInterval)duration;
6359
- (void)pspdf_refreshOrientationWithDuration:(NSTimeInterval)duration; // will be added dynamically

Classes/PSPDFUtils.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,7 @@ + (void)applyOptions:(NSDictionary *)options onObject:(id)object {
8888

8989
// special case handling for annotation name list
9090
if ([key isEqual:@"editableAnnotationTypes"] && [obj isKindOfClass:NSArray.class]) {
91-
obj = [NSMutableOrderedSet orderedSetWithArray:obj];
92-
}
93-
94-
// processed later
95-
else if ([key isEqual:@"lockedInterfaceOrientation"]) {
96-
return; // continue in a block
91+
obj = [NSMutableSet setWithArray:obj];
9792
}
9893

9994
else if ([key.lowercaseString hasSuffix:@"size"] && [obj isKindOfClass:NSArray.class] && [obj count] == 2) {

Classes/TIPSPDFViewController.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ @interface PSPDFViewController (Internal)
1919
- (void)delegateDidShowController:(id)viewController embeddedInController:(id)controller options:(NSDictionary *)options animated:(BOOL)animated;
2020
@end
2121

22-
@interface TIPSPDFViewControllerProxy (PSPDFInternal)
23-
@property (atomic, assign, readonly) UIInterfaceOrientation lockedInterfaceOrientationValue;
24-
@end
25-
2622
@implementation TIPSPDFViewController
2723

2824
///////////////////////////////////////////////////////////////////////////////////////////////////

Classes/TIPSPDFViewControllerProxy.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@
109109
/// Expose the scrollingEnabled property
110110
- (void)setScrollingEnabled:(id)args;
111111

112-
// -1 will reset the lock
113-
- (void)setLockedInterfaceOrientation:(id)arg;
114-
115112
// Save changed annotations.
116113
- (void)saveAnnotations:(id)args;
117114

Classes/TIPSPDFViewControllerProxy.m

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,20 @@ @interface TIPSPDFViewControllerProxy ()
5050

5151
@property (nonatomic) KrollCallback *didTapOnAnnotationCallback;
5252
@property (nonatomic, weak) TiProxy *parentProxy;
53-
@property (atomic, assign) UIInterfaceOrientation lockedInterfaceOrientationValue;
5453
@property (atomic) UIColor *linkAnnotationBorderBackedColor;
5554
@property (atomic) UIColor *linkAnnotationHighlightBackedColor;
5655

5756
@end
5857

5958
@implementation TIPSPDFViewControllerProxy
6059

61-
@synthesize lockedInterfaceOrientationValue = _lockedInterfaceOrientationValue;
62-
6360
///////////////////////////////////////////////////////////////////////////////////////////////////
6461
#pragma mark - Lifecycle
6562

6663
- (id)initWithPDFController:(TIPSPDFViewController *)pdfController context:(id<TiEvaluator>)context parentProxy:(TiProxy *)parentProxy {
6764
if ((self = [super _initWithPageContext:context])) {
6865
PSTiLog(@"init TIPSPDFViewControllerProxy");
6966
self.parentProxy = parentProxy;
70-
self.lockedInterfaceOrientationValue = -1;
7167
self.controller = pdfController;
7268
self.controller.delegate = self;
7369
// As long as pdfController exists, we're not getting released.
@@ -137,7 +133,7 @@ - (void)setLinkAnnotationHighlightColor:(id)arg {
137133
- (void)setEditableAnnotationTypes:(id)arg {
138134
ENSURE_UI_THREAD(setEditableAnnotationTypes, arg);
139135

140-
NSMutableOrderedSet *editableAnnotationTypes = [NSMutableOrderedSet orderedSet];
136+
NSMutableSet *editableAnnotationTypes = [NSMutableSet set];
141137
if ([arg isKindOfClass:NSArray.class]) {
142138
for (__strong NSString *item in arg) {
143139
item = PSSafeCast(item, NSString.class);
@@ -146,8 +142,10 @@ - (void)setEditableAnnotationTypes:(id)arg {
146142
}
147143
}
148144
}
149-
self.controller.document.editableAnnotationTypes = editableAnnotationTypes;
150-
[self.controller reloadData];
145+
146+
[self.controller updateConfigurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
147+
builder.editableAnnotationTypes = editableAnnotationTypes;
148+
}];
151149
}
152150

153151
- (void)setThumbnailFilterOptions:(id)arg {
@@ -276,14 +274,6 @@ - (void)setDidTapOnAnnotationCallback:(KrollCallback *)callback {
276274
}
277275
}
278276

279-
- (id)currentInterfaceOrientation {
280-
__block UIInterfaceOrientation interfaceOrientation;
281-
dispatch_sync(dispatch_get_main_queue(), ^{
282-
interfaceOrientation = self.controller.interfaceOrientation;
283-
});
284-
return @(interfaceOrientation);
285-
}
286-
287277
- (void)saveAnnotations:(id)args {
288278
ENSURE_UI_THREAD(saveAnnotations, args);
289279

@@ -333,14 +323,20 @@ - (void)setOpenInOptions:(id)arg {
333323
- (void)hidePopover:(id)args {
334324
ENSURE_UI_THREAD(hidePopover, args);
335325

336-
BOOL animated = [args count] == 1 && [args[0] boolValue];
326+
BOOL const animated = [args count] == 1 && [args[0] boolValue];
337327
[self.controller.presentedViewController dismissViewControllerAnimated:animated completion:NULL];
338328
}
339329

330+
#define PSPDF_SILENCE_CALL_TO_UNKNOWN_SELECTOR(expression) \
331+
_Pragma("clang diagnostic push") \
332+
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
333+
expression \
334+
_Pragma("clang diagnostic pop")
335+
340336
- (void)showBarButton:(SEL)barButtonSEL action:(id)action {
341337
dispatch_async(dispatch_get_main_queue(), ^{
342-
UIBarButtonItem *barButtonItem = [self.controller performSelector:barButtonSEL];
343-
id sender = action ? [action[0] view] : self;
338+
PSPDF_SILENCE_CALL_TO_UNKNOWN_SELECTOR(UIBarButtonItem *barButtonItem = [self.controller performSelector:barButtonSEL];)
339+
id const sender = action ? [action[0] view] : self;
344340
tipspdf_targetActionBlock(barButtonItem.target, barButtonItem.action)(sender);
345341
});
346342
}

example/app.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ modalButton.addEventListener('click', function(e) {
9494
var pdfController = pspdfkit.showPDFAnimated('PSPDFKit.pdf', 4, // animation option: 0 = no animation, 1 = default animation, 2 = UIModalTransitionStyleCoverVertical, 3 = UIModalTransitionStyleFlipHorizontal, 4 = UIModalTransitionStyleCrossDissolve
9595
// http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
9696
{
97-
lockedInterfaceOrientation : 3, // lock to one interface orientation. optional.
9897
pageMode : 0, // PSPDFPageModeSingle
9998
pageTransition : 2, // PSPDFPageCurlTransition
10099
linkAction : 3, // PSPDFLinkActionInlineBrowser (new default)
@@ -133,10 +132,6 @@ modalButton.addEventListener('click', function(e) {
133132
// get current document path
134133
//var documentPath = pdfController.documentPath;
135134

136-
//UIDeviceOrientationPortrait = 1, UIDeviceOrientationPortraitUpsideDown = 2, UIDeviceOrientationLandscapeLeft = 3, UIDeviceOrientationLandscapeRight = 4, -1 to remove lock.
137-
// there's also currentInterfaceOrientation to query the current state.'
138-
//pdfController.lockedInterfaceOrientation = 3;
139-
140135
//pdfController.showCloseButton = false;
141136

142137
// Changes the link annotation colors to a light red (first hex pair is optional alpha) (or use "clear" to hide)

0 commit comments

Comments
 (0)