【发布时间】:2010-04-23 06:46:49
【问题描述】:
我已将视频和视频的缩略图存储在 Documents 文件夹中。我已经在 plist 中给出了路径。在 plist 中,我获取了一个数组,并将目录添加到数组中。 在字典中我存储了图像路径
/Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/image1
用于关键图像路径。
视频
/Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/video1.mp4
用于密钥文件路径。
我使用了以下代码,但它不起作用。我只尝试图像。我需要将图像加载到每个单元格的表格中。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
UIImageView *image2;
image2.frame = CGRectMake(0.0f, 0.0f, 80.0f, 80.0f);
image2.backgroundColor = [UIColor clearColor];
}
NSDictionary *dictOfplist = [cells objectAtIndex:indexPath.row];
NSString *path = [dictOfplist objectForKey:@"imagePath"];
NSLog("path: %@", path);
return cell;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Library";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(close:)];
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"details" ofType:@"plist"];
contentArray = [NSArray arrayWithContentsOfFile:plistPath];
cells = [[NSMutableArray alloc]initWithCapacity:[contentArray count]];
for(dCount = 0; dCount < [contentArray count]; dCount++)
[cells addObject:[contentArray objectAtIndex:dCount]];
}
我得到的图片路径来自 plist。
但是,如何从路径中提取图像。
输出 od NSLog: 是
path: /Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/snook.jpg
如何从中获取图像并将其存储在 cell.imageView.image 中?
我怎样才能使这项工作。
谢谢。
【问题讨论】:
标签: cocoa-touch iphone-sdk-3.0 uitableview uiimageview