2012-05-26 3 views
0

안녕하세요 여러분, 이미지 파일을 내가 만든 맞춤형 uitableview 셀로 만들 수 없습니다. 이미지가 너무 작아서 그것을 확대하는 방법을 모른다. Thnx 사전에 도움을. 당신의 customCell 클래스에서사용자 정의 UITableViewCell에 맞게 UIImage를 가져올 수 없습니다.

#import <UIKit/UIKit.h> 

@interface customCell : UITableViewCell 
{ 
    //UILabel *frontLabel;  
} 
@property(nonatomic , strong) IBOutlet UILabel *label; 
@property(nonatomic , strong) IBOutlet UILabel *label2; 
@property(nonatomic , strong) IBOutlet UIImageView *imgView; 
@end 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"cell"; 

    customCell * cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
    cell = [[customCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    // cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 


    User * user = [self.list objectAtIndex: indexPath.row]; 

    cell.label.text = user.username; 
    NSString *url = user.profilePic; 
    UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]]; 
    cell.imageView.contentMode =UIViewContentModeScaleAspectFit; 
    cell.imageView.image =image; 

    return cell; 
} 

답변

1

, 당신은 단지 당신이 원하는 정확한 크기와 위치에 imageView 개체의 frame 속성을 설정해야합니다 (대문자로 시작해야 BTW 모든 클래스, 속성과 변수는 소문자이어야 함) .

같은 내용 imageView.frame = CGRectMake(10., 10., 50., 50.) 첫 번째 두 매개 변수는 이미지보기의 오른쪽 위 모서리의 x 및 y 위치이고 두 번째 매개 변수는 너비와 높이입니다.

또는 IBOutlet 's로 지정된 속성이 있으므로 레이아웃에 XIB 파일을 사용하는 경우 이미 크기 설정이 있어야합니다.

XIB 용 인터페이스 빌더 또는 구현 코드 customCell의 스크린 샷을 보지 않으면 내가 도울 수있는 최선의 방법입니다.

+0

thnx,하지만 난 이상한 이미지 뷰 양식 내 사용자 정의 클래스에 액세스 할 수 없습니다. 나는 속성을 설정하고 synth하지만 그것을 시도했지만 self.imageView로 키 ​​워드로 인식하지 못한다. –

+0

음,'UITableViewCell'에는 이미'imageView' 속성이 있기 때문에 확실히 접근 할 수 있어야한다. 당신의'UIImageView'는'imgView'입니다. 내장 된'imageView'를 사용하지 않고'imgView'를 대신 사용할 수 있습니다. –

+0

또한 UITableViewController에서'cell.imageView'를 할 때'cell.imgView'를 사용하여 사용자 정의 셀에 추가 할 수 있습니다. –

관련 문제