如何制作它以便我可以看到所有内容,QLPreviewController的内容位于导航栏下。
文档在TextEdit中看起来像这样。
我正在使用此代码加载内容:
@implementation TextViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.preview = [[QLPreviewController alloc] init];
self.preview.dataSource = self;
self.preview.delegate = self;
[self addChildViewController:self.preview];
[self.view addSubview:self.preview.view];
[self.preview didMoveToParentViewController:self];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidAppear:(BOOL)animated
{
[self.preview refreshCurrentPreviewItem];
}
- (void) loadData: (NSString *)name;
{
assert(![name isEqualToString:@""]);
// Load the plist
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSString *path = [resourcePath stringByAppendingPathComponent:name];
self.info = [[NSDictionary alloc] initWithContentsOfFile:path];
NSString *rtfPath = [resourcePath stringByAppendingPathComponent:[self.info valueForKey:@"transcript"]];
self.url = [NSURL fileURLWithPath:rtfPath];
[self.preview refreshCurrentPreviewItem];
}
- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index
{
if ([QLPreviewController canPreviewItem:self.url]) {
return self.url; // This always returns
}
return nil; // This line is never executed
}
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
return 1;
}
@end
如何让QLPreviewController考虑到导航栏?
答案 0 :(得分:1)
在插入子视图之前执行类似的操作。
CGFloat w= self.view.frame.size.width;
CGFloat h= self.view.frame.size.height;
self.preview.view.frame = CGRectMake(0, 0,w, h);