自定义UIAlertview,实现点击之后,Alertview不消失的效果

经常在项目中,使用强制更新的功能,我们可以使用UIAlertview跳转到APPStore进行更新,但是同时也可以点击左上方的小箭头,返回到之前的APP.这时候,UIAlertview已经消失,我们需要让他依然在,一直在!

import "DGAlertView.h"


#import 

@interface DGAlertView : UIAlertView


- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;

@end

DGAlertView.m

#import "DGAlertView.h"

@implementation DGAlertView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated{
    if (buttonIndex == 0) {
        //[super dismissWithClickedButtonIndex:buttonIndex animated:animated]; // 消失
    }else{
        // ...
        // 不消失
    }
}


@end

重写系统的这个方法,就OK了

- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated

你可能感兴趣的:(自定义UIAlertview,实现点击之后,Alertview不消失的效果)