ios开发中崩溃日志log

来源:互联网 发布:最后的狮子 知乎 编辑:程序博客网 时间:2024/05/23 12:00

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
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 儿子总是不写作业怎么办 长鸡眼脚背肿了怎么办 脚上反复长鸡眼怎么办 脚底长鸡眼很痒怎么办 小脚趾上长鸡眼怎么办 6岁宝宝不爱学习怎么办 上班站久了腿肿怎么办 站时间长了腿肿怎么办 孩子做作业老是粗心大意怎么办 高中孩子没学习兴趣怎么办 初三孩子失去学习兴趣怎么办 初二对学习兴趣不大怎么办 脸上痒发红发肿怎么办 孩子作业拖拉爱丢三落四怎么办 腿肌肉按摩肿了怎么办 孩子上一年级成绩差怎么办 小孩脖子拧筋了怎么办 小孩塑料玩具拧不出来怎么办 一年级孩子做数学题粗心怎么办 手和脚有点肿怎么办 手破了之后肿了怎么办 手指肿了有脓怎么办 宝宝手指红肿有脓怎么办 孩子一听做作业就烦气怎么办 虎皮鹦鹉脚瘸了怎么办 虎皮鹦鹉脚受伤了怎么办 虎皮鹦鹉脚流血了怎么办 虎皮鹦鹉被风扇打到脚怎么办 虎皮鹦鹉脚脱臼了怎么办 孩子作业做得慢怎么办 员工给公司造成损失怎么办 小孩有写不完的作业家长怎么办 一年级孩子作业太粗心怎么办 孩子最近不好好做作业怎么办 工作压力大害怕做不好怎么办 孩子的数算不对怎么办? 孩子计算老是出错怎么办呢 孩子经常计算错误能怎么办 孩子老出现计算错误怎么办 孩子做作业马虎该怎么办 黑笔写错了纸破了怎么办