DatePickerIos.mm

#import <UIKit/UIKit.h>

#import "RootViewController.h"

#import "DatePickerIos.h"

#import "DatePickerView.h"


@interface DatePickerViewController : UIViewController


- (void)show:(std::string)date;


@end


@interface DatePickerViewController () <DatePickerViewDelegate>

@property DatePickerView *dateView;

@end


@implementation DatePickerViewController


- (void)initSelf

{

    DatePickerView *dateView = [[DatePickerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 300)];

    dateView.delegate = self;

    dateView.title = @"请选择时间";

    dateView.cancel = @"取消";

    dateView.confirm = @"确认";

    //    dateView.isSlide = NO;

    //    dateView.date = @"2017-03-23 12:43";

    //    dateView.minuteInterval = 1;

    [self.view addSubview:dateView];

    self.dateView = dateView;

}


// 显示

- (void)show:(std::string)date

{

    if(self.dateView != nil){

        [UIView animateWithDuration:0.3 animations:^{

            self.dateView.frame = CGRectMake(0, self.view.frame.size.height - 300, self.view.frame.size.width, 300);

             NSLog(@"dateView show 显示");

            [self.dateView show];

        }];

    }

}


#pragma mark - THDatePickerViewDelegate

/**

 保存按钮代理方法

 

 @param timer 选择的数据

 */

- (void)datePickerViewSaveBtnClickDelegate:(NSString *)timer {

    NSLog(@"保存点击");

    if (self.dateView == nil) {

        NSLog(@"self.dateView == nil");

        return;

    }

    std::string date = [timer UTF8String];

    cocos2d::Director::getInstance()->getEventDispatcher()->dispatchCustomEvent("DataPickerEvent",&date);

    [UIView animateWithDuration:0.3 animations:^{

        self.dateView.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 300);

        }

                     completion:^(BOOL finished){

                         [self.dateView removeFromSuperview];

                         self.dateView = nil;

                     }

     ];

}


/**

 取消按钮代理方法

 */

- (void)datePickerViewCancelBtnClickDelegate {

    NSLog(@"取消点击");

    if (self.dateView == nil) {

        NSLog(@"self.dateView == nil");

        return;

    }

    [UIView animateWithDuration:0.3 animations:^{

        self.dateView.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 300);

    }completion:^(BOOL finished){

        [self.dateView removeFromSuperview];

        self.dateView = nil;

    }];

}


@end


DatePickerIos *DatePickerIos::datePickerIos = nullptr;


DatePickerIos *DatePickerIos::getInstance()

{

    if(datePickerIos == nullptr)

    {

        datePickerIos = new DatePickerIos();

    }

    

    return datePickerIos;

}


void DatePickerIos::setViewController(void* viewController)

{

    this->viewController = viewController;

    

    datePickerViewController = [[DatePickerViewController alloc] initWithNibName:nil bundle:nil];

    //[((DatePickerViewController*)datePickerViewController) initSelf];

    [((RootViewController*)viewController).view addSubview:((DatePickerViewController*)datePickerViewController).view];

}


void DatePickerIos::show(std::string date)

{

    [((DatePickerViewController*)datePickerViewController) initSelf];

    [((DatePickerViewController*)datePickerViewController) show:date];

}


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liu943367080/article/details/80689251
个人分类: ios-objectc
上一篇DatePickerView.m
下一篇ToastTipIos.mm
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭