2011-11-14 3 views
0

좋아,이 문제로 하루 종일 자살하고 싶습니다. 테이블 크기를 설정했지만 문제는 내가 원하는 크기의 셀을 만들 수 없다는 것입니다. 나는 코드를 넣을 것이다.IPad 프로그래밍 방식으로 UITableViewCell을 만듭니다.

세포의 크기가 변하지 않는 이유는 무엇입니까?

은의 ViewController에 : FotoCell에

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

    FotoCell *cell = (FotoCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[FotoCell alloc] initWithFrame:CGRectMake(0, 0, 50, 90)] autorelease]; 
    } 
     cell.titLabel.text = @"Meeting on iPhone Development"; 
     cell.descLabel.text = @"Sat 10:30"; 
     cell.thumbnail.image = [UIImage imageNamed:@"estadio.jpg"]; 


return cell; 
     } 

: 나는 DynamicTableView에 스크롤

- (void)viewDidLoad { 
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
scroll.pagingEnabled = NO; 
NSInteger size=50; 
for (int i = 0; i < 10; i++) { 
    DynamicTableView *table = [[[DynamicTableView alloc] initWithFrame:CGRectMake(size, 50, 254, 600) style:UITableViewStylePlain] autorelease]; 
    [table setDelegate:table]; 
    [table setDataSource:table]; 
    [scroll addSubview:table]; 
    size+=300; 
} 
scroll.contentSize = CGSizeMake(5000, self.view.frame.size.height); 
[self.view addSubview:scroll]; 
[super viewDidLoad]; 
[scroll release]; 

} 

10 개 테이블을 생성

 - (id)initWithFrame:(CGRect)frame{ 
[super initWithFrame:frame]; 

self.thumbnail = [[[UIImageView alloc] initWithFrame:CGRectMake(10,10,150,90)] autorelease]; 
self.thumbnail.opaque = YES; 

[self.contentView addSubview:self.thumbnail]; 

self.titLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, self.thumbnail.frame.size.height * 0.632, self.thumbnail.frame.size.width, self.thumbnail.frame.size.height * 0.37)] autorelease]; 
self.titLabel.opaque = YES; 
self.titLabel.backgroundColor = [UIColor colorWithRed:0 green:0.4745098 blue:0.29019808 alpha:0.9]; 
self.titLabel.textColor = [UIColor whiteColor]; 
self.titLabel.font = [UIFont boldSystemFontOfSize:11]; 
self.titLabel.numberOfLines = 2; 
[self.thumbnail addSubview:self.titLabel]; 

self.backgroundColor = [UIColor colorWithRed:0 green:0.40784314 blue:0.21568627 alpha:1.0]; 
self.selectedBackgroundView = [[[UIView alloc] initWithFrame:self.thumbnail.frame] autorelease]; 
self.selectedBackgroundView.backgroundColor = kHorizontalTableSelectedBackgroundColor; 

return self; 
    } 

답변

2

당신은

+0

heightForRowAtIndexPath을 구현해야 할 수도 있습니다 그건 테이블 수업 오른쪽에? 내가 그걸 볼 수있는 어떤 생각? –

+0

Apple 문서. UITableViewDelegate. 항상 문서를 살펴보십시오. – Dancreek

+0

많은 사람들, 나에게 이것과 함께 올바른 방향을 제시해. 내가 다시 유감스럽게도, 나는보기를 회전 시키는데 문제가있다. 난 내 모든 clases에있는 방법 - (BOOL) shouldAutorotateToInterfaceOrientation : (UIInterfaceOrientation) interfaceOrientation. YES를 리턴하지만하지는 않습니다. 도움? : D –

관련 문제