나는 코코아에 새로 온 사람과 나는 IKImageBrowserView을 가지고 있고 그것이 내가 여기에 이미지를로드하는 방법은 다음과 같습니다폴더에서 ikimagebrowser에 이미지를로드 하시겠습니까?
- (IBAction)loadImages:(id)sender
{
NSMutableArray *urls = [[NSMutableArray alloc]init];
int i = 1;
for (i=1; i<55; i++) {
NSString *photoNumber = [NSString stringWithFormat:@"%i", i];
NSMutableString *urlString = [[NSMutableString alloc] initWithString:@"Australia"];
[urlString appendString:photoNumber];
NSURL* url = [[NSBundle mainBundle] URLForImageResource:urlString];
[urls addObject:url];
}
[self addImagesWithPaths:urls];
}
- (void)addAnImageWithPath:(NSString *)path
{
myImageObject *p;
/* add a path to our temporary array */
p = [[myImageObject alloc] init];
[p setPath:path];
[_importedImages addObject:p];
}
- (void)addImagesWithPath:(NSString *)path recursive:(BOOL)recursive
{
NSInteger i, n;
BOOL dir;
[[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&dir];
if (dir)
{
NSArray *content = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
n = [content count];
// parse the directory content
for (i=0; i<n; i++)
{
if (recursive)
[self addImagesWithPath:[path stringByAppendingPathComponent:[content objectAtIndex:i]] recursive:YES];
else
[self addAnImageWithPath:[path stringByAppendingPathComponent:[content objectAtIndex:i]]];
}
}
else
{
[self addAnImageWithPath:path];
}
}
/* performed in an independant thread, parse all paths in "paths" and add these paths in our temporary array */
- (void)addImagesWithPaths:(NSArray *)urls
{
NSInteger i, n;
n = [urls count];
for (i= 0; i < n; i++)
{
NSURL *url = [urls objectAtIndex:i];
[self addImagesWithPath:[url path] recursive:NO];
}
/* update the datasource in the main thread */
[self performSelectorOnMainThread:@selector(updateDatasource) withObject:nil waitUntilDone:YES];
}
은 이제 내 이미지는 이름으로로드 - "호주"@. 이미지에 동일한 이름과 번호가 있어야하므로 불편합니다. xcode로 가져온 폴더의 이름이 다른 이미지를 어떻게로드합니까?
그래서 지금은 Australia1, Australia2, Australia3, Australia4 ... 등으로 이미지를로드하고 있습니다. 번들 폴더에서 이미지를로드하려면 어떻게해야합니까?
. 코코아 및 이미지 키트는 OS X에서만 사용할 수 있습니다. –
당신이하려는 일이나 그 대신에 어떤 일이 발생하는지 분명하지 않습니다. "내 이미지가 이름으로로드됩니다 - @"호주 ""라는 뜻입니까? "당신의 이미지는 같은 이름과 번호를 가져야합니다"라는 의미는 무엇입니까? "폴더와 다른 이름으로 이미지로드"는 여기에서하는 것과 어떻게 다른가요? –
나는 그것을 코코아로 태그했다고 생각하지 않는다 ... 음, 어쨌든, 순간에 내 이미지가 루프에 이름으로로드되므로 "Australia1, Australia2, Australia3 ..."라는 이미지가있다. 번들 폴더에서 이미지를 어떻게로드합니까? – Rokas