GithubHelp home page GithubHelp logo

Comments (9)

EdwardBX avatar EdwardBX commented on May 20, 2024 1

1.4.2 已修复。

from pgdatepicker.

xiaozhuxiong121 avatar xiaozhuxiong121 commented on May 20, 2024

什么问题,具体描述一下操作步骤以及出现的错误

from pgdatepicker.

EdwardBX avatar EdwardBX commented on May 20, 2024

麻烦看一下,谢谢

from pgdatepicker.

xiaozhuxiong121 avatar xiaozhuxiong121 commented on May 20, 2024

2017-11-07 9 38 35

这样去设置,用 NSDate+PGCategory类所定义的方法去设置最大日期和最小日期

from pgdatepicker.

EdwardBX avatar EdwardBX commented on May 20, 2024

按照这个方法设置了,选了开始时间2017-08,再去选结束时间,这是结束时间框的显示,还是不对。
tmp7fc80b72

- (void)showDatePicker {
    PGDatePicker *datePicker = [[PGDatePicker alloc] init];
    datePicker.delegate = self;
    datePicker.datePickerMode = PGDatePickerModeYearAndMonth;
    
    NSDateFormatter *dataFormant = [[NSDateFormatter alloc] init];
    [dataFormant setDateFormat: @"yyyyMM"];
    
    // 日历
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSCalendarUnit unit = NSCalendarUnitYear | NSCalendarUnitMonth;
    NSDateComponents *newdateCom = [calendar components:unit fromDate:[NSDate date]];
    datePicker.maximumDate = [NSDate setYear:newdateCom.year month:newdateCom.month];
    
    if ([EMUtil isValidString: self.model.from]) {
        if (!self.chooseFrom) {
            //选择了开始时间再去选结束时间
            NSDate *mindate = [dataFormant dateFromString:self.model.from];
            NSDateComponents *mindateCom = [calendar components:unit fromDate:mindate];
            datePicker.minimumDate = [NSDate setYear:mindateCom.year month:mindateCom.month];
        }
    }
    
    if ([EMUtil isValidString: self.model.to]) {
        if (self.chooseFrom) {
            // 选择了结束时间再去选开始时间
            NSDate *maxdate = [dataFormant dateFromString:self.model.to];
            NSDateComponents *maxdateCom = [calendar components:unit fromDate:maxdate];
            datePicker.maximumDate = [NSDate setYear:maxdateCom.year month:maxdateCom.month];
        }
    }
    
    [datePicker show];
}

from pgdatepicker.

EdwardBX avatar EdwardBX commented on May 20, 2024

就是同时设置 datePicker.maximumDate 和 datePicker.minimumDate 会有问题。单独设置datePicker.maximumDate 是好的。

from pgdatepicker.

xiaozhuxiong121 avatar xiaozhuxiong121 commented on May 20, 2024

我设置同时设置过,我也一直在用,没有出现问题,你现在用的是版本多少,最新的是1.4.1
pod 'PGDatePicker', '>= 1.4.1'
你下载下demo,里面也有同时设置最小日期跟最大日期,也是没有问题的

from pgdatepicker.

xiaozhuxiong121 avatar xiaozhuxiong121 commented on May 20, 2024

可以的话,你留个QQ,我加你,帮你看看

from pgdatepicker.

EdwardBX avatar EdwardBX commented on May 20, 2024

demo里面我看了,当最大时间和最小时间是同一年的时候,就会出错。

- (IBAction)yearAndMonthHandler:(id)sender {
    PGDatePicker *datePicker = [[PGDatePicker alloc]init];
    datePicker.delegate = self;
    [datePicker show];
    datePicker.minimumDate = [NSDate setYear:2015 month:5];
    datePicker.maximumDate = [NSDate setYear:2015 month:10];
    datePicker.datePickerMode = PGDatePickerModeYearAndMonth;
}

tmp0ad6ab6a

from pgdatepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.