Skip to content

Commit

Permalink
Fixed the missing arrow bug when viewing multiple files. Thanks to Bl…
Browse files Browse the repository at this point in the history
…ackwonder for the fix.
  • Loading branch information
rob-brown committed Jul 1, 2011
1 parent 9558a6b commit 3a93120
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
9 changes: 9 additions & 0 deletions RBFilePreviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@

- (id)initWithFile:(id<QLPreviewItem>)file;

/**
* Creates a file previewer from the given files. The array must not be empty.
*
* @param theFiles An array of QLPreviewItems.
*
* @return self
*/
- (id)initWithFiles:(NSArray *)theFiles;

/**
* This should be called before creating RBFileViewer. Quick Look is not
* supported on pre-4.0 devices. Returns YES if Quick Look is supported.
Expand Down
26 changes: 12 additions & 14 deletions RBFilePreviewer.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,14 @@
@interface RBFilePreviewer ()

@property (nonatomic, retain) NSArray * files;

/**
* Creates a file previewer from the given files. There must be at least one
* QLPreviewItem in the array.
*
* @todo Fix this to work with multiple files. For some reason the arrows in
* the UIToolbar disappear.
*
* @param theFiles An array of QLPreviewItems.
*
* @return self
*/
- (id)initWithFiles:(NSArray *)theFiles;
@property (nonatomic, assign) BOOL loadFinished;

@end


@implementation RBFilePreviewer

@synthesize files;
@synthesize files, loadFinished;

- (id)initWithFile:(id<QLPreviewItem>)file {

Expand Down Expand Up @@ -79,6 +67,14 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

// This is a hack to fix the arrow disappearing problem.
- (Class)class {
if ([self loadFinished])
return [super class];
else
return [QLPreviewController class];
}


#pragma mark - QLPreviewControllerDataSource methods.

Expand Down Expand Up @@ -132,6 +128,8 @@ - (void)viewDidAppear:(BOOL)animated {

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

[self setLoadFinished:YES];
}


Expand Down
5 changes: 1 addition & 4 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
`RBFilePreviewer` is a subclass of `QLPreviewController`. It is intended to make it easy to preview any `QLPreviewItem`. All you need to do is pass it the desired item(s) to preview to the appropriate initializer. You may use the provided `RBFile` class or any other class that conforms to `QLPreviewItem` (including `NSURL`).

##Dependencies
`RBFile` requires my `NSURL+RBExtras` category. It can be found in my [RBCategories repository][1]. If you don't use `RBFile`, then you don't need to include `NSURL+RBExtras`.

##Known Bugs
For some weird reason, the arrows that change which item is being previewed don't appear. So, multiple document previewing is disabled by default. It may be re-enabled by moving -initWithFiles: into the header file. Better yet, the bug could be fixed. Hopefully this bug is not due to `QLPreviewController` being unsafe to subclass.
`RBFile` requires my `NSURL+RBExtras` category. It can be found in my [RBCategories repository][1]. `RBFile` is optional, so if you don't include it, then you don't need to include `NSURL+RBExtras`.

##License

Expand Down

0 comments on commit 3a93120

Please sign in to comment.