Я сохранил видео и миниатюры изображений в папке «Документы». И я дал путь в plist. В plist я взял массив, и я добавил каталоги в массив. И в словаре я хранил путиКак загружать изображения из plist в UITableView?
/Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/image1
изображения для ключа ImagePath.
для видео
/Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/video1.mp4
для ключа Filepath.
Я использовал следующий код, но он не работает. Я пытаюсь только для изображений. Мне нужно, чтобы изображения загружались в таблицу в каждой ячейке.
- (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]];
}
У меня есть путь к изображениям из плиты.
Но как я могу извлечь изображение из пути.
Выход спосо NSLog: это
path: /Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/snook.jpg
Как я могу получить изображение из него и хранить в cell.imageView.image?
Как я могу выполнить эту работу. Спасибо.
Я думал, что передача ключевого значения словаря в plist дает путь. Виноват. Я сохранил путь в словаре в plist для значения ключа imagePath. Как мы можем получить путь от plist в наш код? Я проверю свой код и исправлю его. Спасибо. –
У меня есть путь к изображению. но как получить изображение от него? Путь: Путь:/Пользователи/srikanth/Библиотека/Поддержка приложений/Симулятор iPhone/Пользователь/Приложения/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/snook.jpg Как показать изображение snook.jpg из путь в ячейке? –
Использовать метод «imageWithContentsOfFile:» для UIImage: UIImage * img = [UIImage imageWithContentsOfFile: путь]; –