2012-06-22 4 views
3

세포의 액세서리보기를 설정하려고합니다. UIButton입니다. 그러나 그것은 보여지지 않습니다.이미지가있는 사용자 정의 UIButton

다음은 화상에 따라 그 크기를 조정하는 코드

UIButton *accessory = [UIButton buttonWithType:UIButtonTypeCustom]; 
[accessory setImage:[UIImage imageNamed:@"plus.png"] forState:UIControlStateNormal]; 
[cell setAccessoryView:accessory]; 
+0

try [cell.contentView 액세서리]; 및 요구 사항에 따라 위치 액세서리. – rptwsthi

답변

6

통화 [accessory sizeToFit];이다.

0

당신은 다음과 같이 수행이

UIButton *accessory = [UIButton buttonWithType:UIButtonTypeCustom]; 
[accessory setImage:[UIImage imageNamed:@"plus.png"] forState:UIControlStateNormal]; 
//Set the accessory frame 
accessory.frame = CGRectMake(0, 0, 100, 100); 
0
UIView* accessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 24, 50)]; 
UIImageView* accessoryViewImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"]]; 
accessoryViewImage.center = CGPointMake(12, 25); 
[accessoryView addSubview:accessoryViewImage]; 
[cell setAccessoryView:accessoryView]; 
[accessoryViewImage release]; 
[accessoryView release]; 

처럼이 액세서리에 프레임을 설정해야합니다.

관련 문제