QLPreviewController-设置PreviewItemTitle [英] QLPreviewController - setting previewItemTitle

查看:328
本文介绍了QLPreviewController-设置PreviewItemTitle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何为我的QLPreviewController类设置PreviewItemTitle属性.似乎有点奇怪,因为此类的iPhone开发人员文档说该属性为@property (readonly),这意味着我无法设置它.

I can't work out how to set the previewItemTitle property for my QLPreviewController class. Its seems a bit strange as the iPhone developer document for this class says that that property is @property (readonly) which would mean that I cannot set it.

任何想法.谢谢

我的代码:

QLPreviewController *preview = [[QLPreviewController alloc] init];
    [preview setDataSource:self];

    [self presentModalViewController:preview animated:YES];

推荐答案

QLPreviewController没有PreviewItemTitle属性.您的意思是QLPreviewItem 协议.

QLPreviewController has no previewItemTitle property. You mean the QLPreviewItem protocol.

只读"表示您不能通过属性设置它(除非它被覆盖);即该属性未声明setPreviewItemTitle:方法.这对于该协议很有意义:控制器不希望能够设置预览项目的标题.

"Readonly" means that you can't set it via the property (unless it's overridden); i.e. the property does not declare a setPreviewItemTitle: method. This makes sense for the protocol: the controller does not expect to be able to set the preview item titles.

对于最基本的预览项目,您可以使用以下内容:

For the most basic preview item, you could use something like this:

@interface BasicPreviewItem : NSObject<QLPreviewItem>
{
}

@property (nonatomic, retain) NSURL * previewItemURL;
@property (nonatomic, copy) NSString* previewItemTitle;

@end

@implementation BasicPreviewItem

@synthesize previewItemURL, previewItemTitle;

-(void)dealloc
{
  self.previewItemURL = nil;
  self.previewItemTitle = nil;
  [super dealloc];
}

@end

但是,协议的重点是让您可以使用 any 类并添加-(NSURL*)previewItemURL-(NSString*)previewItemTitle方法(例如,如果您有音乐播放器,则可以将这些方法添加到跟踪"类,并可以预览轨道.

However, the point of the protocol is so that you can take any class and add -(NSURL*)previewItemURL and -(NSString*)previewItemTitle methods (e.g. if you had a music player, you could add those methods to the "Track" class and be able to preview tracks).

这篇关于QLPreviewController-设置PreviewItemTitle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆