こんにちは私はXcodenobjectiveに不慣れです-Cはこれについて助けが必要です。ボタンなしのUIAlertViewがあり、クリックすると閉じられますが、アラートボックスの内側ではなく外側をクリックしたときにのみ閉じます。ありがとう
//generating the alertview with no button
+(void) showAlertNoButtons:(NSString*)title text:(NSString*)text{
UIAlertView* alertView = [[UIAlertView alloc]
initWithTitle:title message:text
delegate:self cancelButtonTitle:nil
otherButtonTitles:nil];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(dismissAlert:)];
alertView.delegate=self;
[alertView addGestureRecognizer:singleTap];
[alertView setMultipleTouchEnabled:YES];
[alertView setUserInteractionEnabled:YES];
[alertView show];
}
//
+(void)dismissAlert:(UITapGestureRecognizer *)gesture
{
UIAlertView* alertView =(UIAlertView *)gesture.view;
[alertView dismissWithClickedButtonIndex:0 animated:YES];
}