기본보기에 사용자 정의보기를 추가하고보기에서 단추를 만들고 단추를 표시하고 있지만 단추를 눌러도 작업이 수행되지 않습니다. 버튼을 탭하여 사진 갤러리를 열고 싶습니다. 버튼을 누르면 루프가 생성됩니다. 난이 사용하고UIButton 선택기가 주 창보기에서 작동하지 않습니다.
코드 ... 또한
UIImage *image=[[UIImage alloc] initWithData:data cache:NO];
UIImageView *iv=[[UIImageView alloc] initWithFrame:CGRectMake(200, y, 75, 75)];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(200, y, 75, 75)];
[button setAlpha:0];
[button setTag:i];//change this to your loop counter
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
iv.image=image;
// [email protected]"bigimage.jpg";
iv.userInteractionEnabled=YES;
button.userInteractionEnabled = YES;
[iv addSubview:button];
[button release];
y=y+145;
[view1 addSubview:iv];
[iv release];
그리고이 코드를 시도하지만 개선이없는 .....
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(200, y, 75, 75);
UIImage *img = [[UIImage alloc] initWithData:data];
[button setBackgroundImage:img forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
button.tag = i;
y = y+145;
[view1 addSubview:button];
왜 이미지보기에 단추를 추가하고 있습니까? –
버튼에 이미지가 표시되지 않아야합니다. – shivangi
@shivangi : 버튼의 배경 이미지로 이미지를 추가해야합니다. – Maulik