ios开发中崩溃日志log

typedef enum{
QFLogLevelFail = 0,
QFLogLevelError,
QFLogLevelWarning,
QFLogLevelInfo,
QFLogLevelDebug

}QFLogLevel;
void QFLogMessage(QFLogLevel level, BOOL waitUntilDone, NSString* message, …);
@interface QFLog : NSObject
{
QFLogLevel _level;
BOOL _isStarted;
NSThread *_thread;

NSString* _logDirectory;//日志文件目录
NSFileHandle *_fileHandle;//日志文件句柄
NSString* _logName;//日志文件名

NSArray *_theLevelStringArray;

NSDateFormatter *_dateFormatter;

}
@property (nonatomic, readwrite, assign) QFLogLevel level;

/**
* QFLog Singleton对象
*
* @return QFLog对象
*/
+ (QFLog *)sharedQFLog;

/**
* 开始记录日志
*/
- (void)startLogging;

/**
* 停止记录日志
*/
- (void)stopLogging;

  • (BOOL)isFinished;

/**
* 删除旧日志
*/
- (void)removeOldLogs;

/**
* 上传日志
*/
- (void)uploadLogs;

@end

import “Dialog.h”

static UIWindow *g_alertWindow = nil;

@interface DialogViewController : UIViewController
{
UIView *_dialogView;
BOOL _modal;
}

@property(assign, readwrite, nonatomic) BOOL modal;

  • (void)setDialogView:(UIView *)dialogView;

@end

@implementation DialogViewController

  • (void)dealloc
    {
    [_dialogView release];
    _dialogView = nil;

    [super dealloc];
    }

  • (void)touchesBegan:(NSSet )touches withEvent:(UIEvent )event
    {
    if (_modal)
    {
    return;
    }

    UITouch *touch = [touches anyObject];

    CGPoint touchPoint = [touch locationInView:self.view];

    if ( !CGRectContainsPoint(_dialogView.frame, touchPoint))
    {
    //关闭对话框
    closeDialogView(QFCloseDialogViewAnimationNone, ^(BOOL finished) {

    });
    

    }
    }

  • (void)viewDidLoad
    {
    [super viewDidLoad];

}

  • (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {

    CGFloat mainScreenWidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat mainScreenHeight = [UIScreen mainScreen].bounds.size.height;

    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
    ||
    toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
    _dialogView.center = CGPointMake(mainScreenHeight/2.0, mainScreenWidth/2.0);
    }
    else
    {
    _dialogView.center = CGPointMake(mainScreenWidth/2.0, mainScreenHeight/2.0);
    }
    }

  • (void)setDialogView:(UIView *)dialogView
    {
    [dialogView retain];
    [_dialogView release];
    _dialogView = dialogView;

    CGFloat mainScreenWidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat mainScreenHeight = [UIScreen mainScreen].bounds.size.height;

    UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;

    if (orientation == UIDeviceOrientationLandscapeLeft
    ||
    orientation == UIDeviceOrientationLandscapeRight)
    {
    _dialogView.center = CGPointMake(mainScreenHeight/2.0, mainScreenWidth/2.0);
    }
    else
    {
    _dialogView.center = CGPointMake(mainScreenWidth/2.0, mainScreenHeight/2.0);
    }

    [self.view addSubview:dialogView];
    }

@end

void showDialogView(UIView *view, BOOL modal, QFShowDialogViewAnimationOptions showDialogViewAnimationOption, void (^completion)(BOOL finished))
{
if (g_alertWindow == nil)
{
g_alertWindow = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];

    g_alertWindow.windowLevel = UIWindowLevelAlert;

    g_alertWindow.backgroundColor = [UIColor clearColor];

    [g_alertWindow makeKeyAndVisible];
}

DialogViewController *dialogViewController = [[[DialogViewController alloc] init] autorelease];

dialogViewController.modal = modal;

g_alertWindow.rootViewController = dialogViewController;

[dialogViewController setDialogView:view];

if (showDialogViewAnimationOption == QFShowDialogViewAnimationNone)
{

    if (completion != nil)
    {
        completion(YES);
    }
    return;
}
else if (showDialogViewAnimationOption ==QFShowDialogViewAnimationFromLeft)
{
    view.layer.transform = CATransform3DTranslate(view.layer.transform, -g_alertWindow.bounds.size.width, 0, 0);
}
else if (showDialogViewAnimationOption ==QFShowDialogViewAnimationFromTop)
{
    view.layer.transform = CATransform3DTranslate(view.layer.transform, 0, -g_alertWindow.bounds.size.height, 0);
}
else if (showDialogViewAnimationOption ==QFShowDialogViewAnimationFromRight)
{
    view.layer.transform = CATransform3DTranslate(view.layer.transform, g_alertWindow.bounds.size.width, 0, 0);
}
else if (showDialogViewAnimationOption ==QFShowDialogViewAnimationFromBottom)
{
    view.layer.transform = CATransform3DTranslate(view.layer.transform, 0, g_alertWindow.bounds.size.height, 0);
}
else if (showDialogViewAnimationOption ==QFShowDialogViewAnimationFromCenter)
{
    view.layer.transform = CATransform3DScale(view.layer.transform, 0.001, 0.001, 1);
}


[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

 view.layer.transform = CATransform3DIdentity;

 } completion:^(BOOL finished) {

    if (completion != nil)
    {
        completion(YES);
    }
 }];

}

void closeDialogView(QFCloseDialogViewViewAnimationOptions closeDialogViewViewAnimationOption, void (^completion)(BOOL finished))
{
CATransform3D transform;

if (closeDialogViewViewAnimationOption == QFCloseDialogViewAnimationNone)
{
    if (g_alertWindow != nil)
    {
        [g_alertWindow release];
        g_alertWindow = nil;
    }

    if (completion != nil)
    {
        completion(YES);
    }
    return;
}
else if (closeDialogViewViewAnimationOption == QFCloseDialogViewAnimationToLeft)
{
    transform = CATransform3DTranslate(g_alertWindow.rootViewController.view.layer.transform, -g_alertWindow.frame.size.width, 0, 0);
}
else if (closeDialogViewViewAnimationOption == QFCloseDialogViewAnimationToTop)
{
    transform = CATransform3DTranslate(g_alertWindow.rootViewController.view.layer.transform, 0, -g_alertWindow.frame.size.height, 0);
}
else if (closeDialogViewViewAnimationOption == QFCloseDialogViewAnimationToRight)
{
    transform = CATransform3DTranslate(g_alertWindow.rootViewController.view.layer.transform, g_alertWindow.frame.size.width, 0, 0);
}
else if (closeDialogViewViewAnimationOption == QFCloseDialogViewAnimationToBottom)
{
    transform = CATransform3DTranslate(g_alertWindow.rootViewController.view.layer.transform, 0,g_alertWindow.frame.size.height, 0);
}
else if (closeDialogViewViewAnimationOption == QFCloseDialogViewAnimationToCenter)
{
    transform = CATransform3DScale(g_alertWindow.rootViewController.view.layer.transform, 0.001, 0.001, 1);
}


[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

 g_alertWindow.rootViewController.view.layer.transform = transform;

 } completion:^(BOOL finished) {

    if (g_alertWindow != nil)
    {
        [g_alertWindow release];
        g_alertWindow = nil;
    }

    if (completion != nil)
    {
        completion(YES);
    }

 }];

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值