我有一个功能,可以让你选择如何拍照(从画廊或从相机)。如果没有“内容”(你还没有拍照),那么你可以自由地做到这一点。如果确实有内容(您已经拍了照片),那么会弹出一个对话框询问您是否确定。我已经实现了UIAlertViewDelegate,以便我可以告诉他们按哪个按钮。UIAlertView不会调用功能
当我们按OK键(按钮索引0),但功能不起作用(它确实被调用,我用调试器逐步完成)时出现问题。如果再次按下按钮,它也不会让我弹出另一个对话框。
我不知道问题出在哪里,我无法想象谷歌能够尝试找出什么。
任何帮助表示赞赏,谢谢。
-(IBAction)galleryButtonPressed:(id)sender
{
if (!mHasContent)
{
[mDelegate performSelector:@selector(galleryButtonPressed:) withObject:self];
}
else
{
UIAlertView* warning = [[UIAlertView alloc] initWithTitle:@"Section Complete" message:@"You have already taken an image. Selecting another will overwrite it, you can select to take another image above. Are you sure you wish to continue?" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: @"Cancel", nil];
[warning setTag:GALLERY];
[warning show];
[warning release];
}
}
-(IBAction)cameraButtonPressed:(id)sender
{
if (!mHasContent)
{
[mDelegate performSelector:@selector(captureImageButtonPressed:) withObject:self];
}
else
{
UIAlertView* warning = [[UIAlertView alloc] initWithTitle:@"Section Complete" message:@"You have already taken an image. Selecting another will overwrite it, you can select to take another image above. Are you sure you wish to continue?" delegate:self cancelButtonTitle:nil otherButtonTitles: @"OK", @"Cancel", nil];
[warning setTag:CAMERA];
[warning show];
[warning release];
}
}
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
// If they selected OK then resend the event to take a photo or select from the gallery
if (buttonIndex == 0)
{
mHasContent = NO;
if ([alertView tag] == GALLERY)
{
[self galleryButtonPressed:mGalleryButton];
}
else
{
[self cameraButtonPressed:mCameraButton];
}
}
}
我也尝试过这与onClick和willDismiss ....并没有这些工作。
对不起,我应该说。我已经尝试过,并且还有“willDissWithButtonIndex”,而且他们都不工作。 – Luke 2012-02-27 09:52:02