내 시스템 환경 설정 프로젝트에서 NSImages를 해결할 수없는 것 같습니까?시스템 환경 설정 NSImage가 해결되지 않습니다
이미지는 내 xcode 프로젝트의 내 기본 폴더에있는 user.png입니다.
편집 : Source Code에 대한 링크가 포함되어 있습니다. 희망을 갖고 누군가가 문제를 발견 할 수 있기를 바랍니다.
PersonController.m
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
Person *person = [personsList objectAtIndex:row];
if (tableColumn == listGender) {
if ([person.gender isEqualToString: @"m"]) {
/****************************
* Method - 1: Doesn't work
****************************/
NSImage *image = [NSImage imageNamed:@"user.png"];
NSLog(@"image is valid? %@", [image isValid] ? @"yes" : @"no");
return image;
// return @"male";
}
else {
/****************************
* Method - 1: Doesn't work
****************************/
NSImage *image = [NSImage imageNamed:@"user_female.png"];
NSLog(@"image is valid? %@", [image isValid] ? @"yes" : @"no");
return image;
// return @"female";
}
}
else if (tableColumn == listName) {
return [person valueForKey:@"name"];
}
else {
return nil;
}
}
또한, 지정이 경로가 작동하지만, 내가 왜 전체 경로를 지정해야합니까?
NSImage *myImage = [[NSImage alloc] initByReferencingFile:@"/Users/coderama/sandbox/Persons/user.png"];
다른 mac에서 작동하는 앱을 원한다면 아래의 대답 에서처럼 mainBundle을 사용하는 것이 좋습니다 –
제안에 대해 모두 감사하지만 불행히도 그들 중 누구도 일하지 않았습니다. 소스 코드의 업데이트를 참조하십시오. 누군가가 문제를 발견 할 수 있기를 바랍니다. 또한 도움을 주신 모든 분들께 +1 – Coderama