문제

내 문제는 얻을 수 없는 이미지에서 내 번들을 올바르게 표시됩니다.이 방법은 보기에는 컨트롤러 컨트롤 tableview. headerView 로 tableview 니다.펜촉 파일을 포함하 UILabels(하지 않음)로드됩니다.어떤 아이디어가?

- (void)viewDidLoad {
    [super viewDidLoad];

    [[self view] setTableHeaderView:headerView];
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *imagePath = [bundle pathForResource:@"awesome_lolcat" ofType:@"jpeg"];
    UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
    imageView = [[UIImageView alloc] initWithImage:image];
}
도움이 되었습니까?

해결책

는 경우에 당신은 이미 만든 콘센트에 연결 하에서 보기 인터페이스 빌더,를 사용해야 할 보기보다는 만드는 반환</니다.


   //this assumes that headerView is an already created UIView, perhaps an IBOutlet
   //also, imageViewOutlet is an IB outlet hooked up to a UIImageView, and added as
   //a subview of headerView.

   //you can also set the image directly from within IB
   imageViewOutlet.image = [UIImage imageNamed: @"awesome_lolcat.jpeg"];
   [[self view] setTableHeaderView: headerView];

다른 팁

먼저 당신이 필요가 있는지 여부를 알아내는 이미지를 로드하는니다.을받을 수있는 가장 빠른 방법은 이미지를 사용하 있는 uiimage 편의 방법+[있는 uiimage imageNamed:rawImageName].

또한,이 UITableViewController?(이것은 분명하지 않지만 묵시적으).

어디에이 이미지 뷰을 사용하고 있습니까?당신이 그것을 만드는 아래쪽,하지만 보이지 않는 아무것도 할 필요합니다.당신은 아마 이미지를 만들 보기에 할당,이미지,그리고 다음에 추가로 서브뷰를 headerView.


   //this assumes that headerView is an already created UIView, perhaps an IBOutlet

   UIImage     *image = [UIImage imageNamed: @"awesome_lolcat.jpeg"];
   UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
   [headerView addSubview: [imageView autorelease]];
   [[self view] setTableHeaderView: headerView];

추가 하위 보기 프로그래밍 방식으로 일했지만,그렇지 않은 제대로 연결 반환</ 에서 인터페이스 빌더입니다.View 내가 만들(나는 생각한다)올바르게 연결 UIView 아울렛에서 나 UITableViewController, 지만,때 나는 init 이미지 뷰 내은 도움말 페이지를 참조하기 대신 이미지 뷰에서 내가 이미 만들어집니다.

답변 감사합니다.

http://developer.apple.com/library/ios/#samplecode/TableViewUpdates/Introduction/Intro.html 그것은이 전시에 반환</섹션에는 헤더가 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top