@protocol UIAlertViewDelegate <NSObject>
@optional
// Called when a button is clicked. The view will be automatically dismissed after this call returns
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
// If not defined in the delegate, we simulate a click in the cancel button
- (void)alertViewCancel:(UIAlertView *)alertView;
- (void)willPresentAlertView:(UIAlertView *)alertView; // before animation and showing view
- (void)didPresentAlertView:(UIAlertView *)alertView; // after animation
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex; // before animation and hiding view
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex; // after animation
// Called after edits in any of the default fields added by the style
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView;
@endself.usageAlertView = [[UIAlertView alloc] initWithTitle:@"Usage"
message:message
delegate:self
cancelButtonTitle:@"Launch Safari"
otherButtonTitles:nil];如果需要处理UIAlertView对象所触法的所有事件,设置成delegate:self,否则设置呈delegate:nil
本文详细介绍了如何在iOS应用中通过设置UIAlertViewDelegate来处理弹窗的各个事件,包括点击按钮、取消弹窗、弹窗显示前后的状态变化等。通过实现这些方法,开发者可以更灵活地控制和响应弹窗的行为。

3001

被折叠的 条评论
为什么被折叠?



