2013-01-07 5 views
1

이 질문은 자주 묻는 질문입니다. uiAlertView에 다른 컨트롤을 표시하는 방법입니다. 내보기에 이미지가있는 앱이 있는데 사용자가 해당 이미지를 탭하면 확대하고 싶습니다. 그래서, 나는 확대와 함께 동일한 이미지로 uialertview에서 팝업 할 수있는 옵션이 있습니다. 잘 시도해도 올바른 해결책이 아닙니다. 당신은 내가 더 줄 경우 확인 에 겹쳐 볼 수 있다면 아래 이미지가 uialertview ...?

enter image description here

, 내가 \ n \ n 메시지주고있다 여기에 내 코드

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NULL message:@"\n\n\n\n\n\n\n\n\n\n\n\n\n" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
UIImage *image = [UIImage imageNamed:@"GM00132002062125.png"]; 
UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 
CGFloat imageHeight = 250; 
CGFloat imageWidth = imageHeight * image.size.width/image.size.height; 
imageView.frame = CGRectMake(floor((284 - imageWidth)/2), 47, imageWidth, imageHeight); 
[alert addSubview:imageView]; 
[alert show]; 

입니다 \ n 메시지에

enter image description here

...이

감사

+0

이미지 크기를 줄일 수 있습니까? – IronManGill

+0

실제로보기 이미지는 크기가 작습니다. 사용자가 이미지를 탭하면 확대해야합니다. 팝업 이미지 크기를 줄이면 사용하지 못합니다. –

+0

이 질문을 확인하십시오. http://stackoverflow.com/questions/2323557/image-in-uialertview –

답변

1

사용이 울부 짖는 코드에 대한 특별한 해결책이 없다

UIImageView *imageView = [[UIImageView alloc] initWithFrame:setYourFrameHere]; 

    NSString *imgPath = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"GM00132002062125.png"]]; 
    UIImage *yourImage = [[UIImage alloc] initWithContentsOfFile:imgPath]; 
    [imageView setImage:yourImage]; 
    [yourImage release]; 
    [imgPath release]; 

    [alert addSubview:imageView]; 
    [imageView release]; 

    [alert show]; 
    [alert release]; 

UPDATE : 센터

이미지 또는 우리의보기에 일부있는 CustomView 전 벨로우즈 코드 의이 유형을 사용하십시오.이 시도 ...

myCustomView.frame = CGRectMake(floorf(backgroundView.size.width - customView.size.width/2.0f), 0.0, myCustomView.size.widht, myCustomView.size.height); 
+0

답장을 보내 주셔서 감사합니다. Paras Joshi,하지만 내 코드를 확인해야한다고 생각합니다. 그것은 당신 것과 거의 같습니다. 오히려 적당한 크기의 사양을 넣는 것만으로. –

+0

위의 코드로 이미지를 가운데에 놓으려고하면 alertView의 중심에 imageView를 사용하면 코드가 변경 될 수 있습니다. 그리고 작동합니다 .. –

+0

Thanks, CGFloat imageHeight = 250; CGFloat imageWidth = imageHeight * image.size.width/image.size.height; imageView.frame = CGRectMake (바닥 ((284 - imageWidth)/2), 47, imageWidth, imageHeight); 나는 이것을 똑같이하고있다. –