ios CCUIAlertActivityView.m

objectivec 复制代码
//
//  CCUIAlertActivityView.h
//  CCFC
//
//


#import <Foundation/Foundation.h>




@interface CCUIAlertActivityView : UIView
{
        UIAlertView                             *_alertView;
        UIActivityIndicatorView *_activityView;
        
        float                                   _disappearTime;
}


// if set 0, then it won't disappear until you hide it.
@property(nonatomic, assign)    float   disappearTime;


- (id)initWithTitle:(NSString *)title;
- (void)dealloc;


- (void)show;
- (void)hide;


@end
objectivec 复制代码
//
//  CCUIAlertActivityView.m
//  CCFC
//
//


#import "CCUIAlertActivityView.h"
#import "CCNSNumber.h"
#import "CCUIView.h"
#import "CCCommon.h"
#import "CCLog.h"


@implementation CCUIAlertActivityView


@synthesize disappearTime = _disappearTime;


- (id)initWithTitle:(NSString *)title
{
        self = [super init];
        if(self)
        {
                _alertView = [[UIAlertView alloc] initWithTitle:title
                                                                                                message:nil
                                                                                           delegate:self
                                                                          cancelButtonTitle:nil
                                                                          otherButtonTitles:nil];


                _activityView = [[UIActivityIndicatorView alloc] 
                                                 initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
                _activityView.frame = CGRectMake(0, 0, 20, 20);
                [_alertView addSubview:_activityView];
                [_activityView release];
        }
        return self;
}


- (void)dealloc
{
        [super dealloc];
}


- (void)onDisappear:(id)timer PRIVATE_FLAG
{
        [_activityView stopAnimating];
        [_alertView dismissWithClickedButtonIndex:0 animated:YES];
}


- (void)show
{
        [_alertView show];


        [_activityView setCenterOf:_alertView];
        [_activityView startAnimating];
        [_alertView release];
        if(!FLOAT_EQUAL_TO_ZERO(_disappearTime))
        {
                [NSTimer scheduledTimerWithTimeInterval:_disappearTime
                                                                                 target:self
                                                                           selector:@selector(onDisappear:)
                                                                           userInfo:nil
                                                                                repeats:NO];
        }
}


- (void)hide
{
        [_alertView dismissWithClickedButtonIndex:0 animated:YES];
}


@end

微风不燥,阳光正好,你就像风一样经过这里,愿你停留的片刻温暖舒心。

我是程序员小迷(致力于C、C++、Java、Kotlin、Android、Shell、JavaScript、TypeScript、Python等编程技术的技巧经验分享),若作品对您有帮助,请关注、分享、点赞、收藏、在看、喜欢,您的支持是我们为您提供帮助的最大动力。

欢迎关注。助您在编程路上越走越好!

相关推荐
CHB5 小时前
uni-app x 蒸汽模式 性能测试基准报告 Benchmark【Android版】
android·ios·uni-app
Magic-ZYJ6 小时前
不登录、不联网也能用:我是如何设计一款“本地优先”iOS App 的
ios·app·iphone·研发·独立开发者·心情日记
_阿南_8 小时前
flutter 展示的字体突然奔放了
android·flutter·ios
90后的晨仔12 小时前
你的 iOS 最低部署版本即将不再被 App Store 接受
ios
2601_9657984715 小时前
Launch Your Wellness App Fast: The Truth About Meditation Source Code
前端·macos·ios·objective-c·cocoa
初级代码游戏1 天前
iOS开发 Swift 速记7:结构体和类
开发语言·ios·swift
Anhty1 天前
手机端叮咚变声器2026实测:功能表现、优缺点完整解析
功能测试·ios·智能手机·安卓
SameX2 天前
后台定位耗电的问题,我花两年把它压到了3%-5%
ios
星辰即远方2 天前
计算器仿写总结
学习·ui·ios·cocoa·xcode
游戏开发爱好者82 天前
系统状态:专为iPhone和iPad设计的实时系统性能监控工具全面介绍
android·ios·小程序·uni-app·iphone·webview·ipad