셀의 완전히 다른 2 가지 모양 (및 내용)을 설정하고 싶습니다. (하나는 선택되고 하나는 선택되지 않음).UITableView 셀 : backgroundBack을 표시하지 않고 selectedBackgroundView
이 코드는 작동하지만 선택한 셀의 이미지가 50 % 투명하기 때문에 맨 아래에 BackgroundView가 표시됩니다.
clearBackgroundView는 선택된 경우에만 표시되는 요소로 셀을 채우는 좋은 방법을 제공합니다. BackgroundView 셀을 채우는 것보다 다른 위치가되어, 위치는 어떻게
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"hello";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
UIImage *image = [UIImage imageNamed:@"listview_btn.png"];
UIImage *imageThumb = [UIImage imageNamed:@"01_thumb.jpg"];
UIImageView* imageView = [[UIImageView alloc] initWithImage:imageThumb];
[imageView setFrame:CGRectMake(0, 0, 50, 67)];
[cell setBackgroundView:[[UIImageView alloc]initWithImage:image] ];
[cell.backgroundView addSubview:imageView];
UIImage *imageSel = [UIImage imageNamed:@"listview_btn_on.png"];
UIImage *imageThumbSel = [UIImage imageNamed:@"01_thumb_Sel.jpg"];
UIImageView* imageViewSel = [[UIImageView alloc] initWithImage:imageThumbSel];
[imageViewSel setFrame:CGRectMake(110, 0, 50, 67)];
[cell setSelectedBackgroundView:[[UIImageView alloc]initWithImage:imageSel] ];
[cell.selectedBackgroundView addSubview:imageViewSel];
코드 서식을 수정하기 위해 한 번의 클릭 만 필요했습니다. 어쩌면 다음 번에 클릭하면됩니다. 이렇게하려면 질문에 삽입 한 코드를 모두 선택하고'{}'버튼을 누릅니다. 코드가 읽기 쉽고 좋은 색 구성표를 얻을 수 있도록 적절한 markdown 들여 쓰기가 추가됩니다 :-) –
물론 xcode가 아닌 [Xcode] (http://stackoverflow.com/a/5725282/457406)입니다. Xcode는 iPhone이 아닙니다. Xcode는 IDE 일뿐 아니라 코드를 작성하는 도구입니다. 귀하의 질문이 IDE 자체와 관련이 없다면 (예 : "Xcode에서 줄 번호를 어떻게 켜야합니까?") –
이 질문에 대한 답변이 없습니까? (Matthias에게 감사드립니다) – Franck