2017-09-28 3 views
2

を使用してiOSの中で、前の日、月、年JTAppleCalendarを無効にする:
https://github.com/orazz/CalendarPopUpは、私はこのライブラリを使用していスウィフト3.0

のは、私は、ユーザーの登録の日付を持っており、それが28/9/2017だとしましょう。今では、次の日付、月、年の間でのみ日付を有効にしたいと考えています。 以前の日付、月、および年を無効にする必要があります。

どうすればいいですか?

スクロールを無効にして前の日付と月を選択するにはどうすればよいですか?

enter image description here

+0

? –

+0

@ iOSカレンダービューonMyProfile 'JTAppleCalendar'、 '6.0' –

+0

ok、あなたは 'canSelect'または' shouldSelect'デリゲート関数を持っていますか? 'ture'または' false'のいずれかを返すことによって日付が選択されないようにすることができます –

答えて

0

最小と最大の日付を設定するために使用します。日、月、年などの任意のコンポーネントを変更することができます。

Objective Cの

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 
NSDate *currentDate = [NSDate date]; 
NSDateComponents *comps = [[NSDateComponents alloc] init]; 
[comps setMonth:3]; 
NSDate *maxDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0]; 
[comps setMonth:-3]; 
NSDate *minDate = [calendar dateByAddingComponents:comps toDate:currentDate options:0]; 
[datePicker setMaximumDate:maxDate]; 
[datePicker setMinimumDate:minDate]; 

スウィフトあなたはどのバージョンを使用している

let gregorian: NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)! 
let currentDate: NSDate = NSDate() 
let components: NSDateComponents = NSDateComponents() 

components.month = -3 
let minDate: NSDate = gregorian.dateByAddingComponents(components, toDate: currentDate, options: NSCalendarOptions(rawValue: 0))! 

components.month = 3 
let maxDate: NSDate = gregorian.dateByAddingComponents(components, toDate: currentDate, options: NSCalendarOptions(rawValue: 0))! 

self.datePicker.minimumDate = minDate 
self.datePicker.maximumDate = maxDate 
+0

サンドコードありがとうございますが、私の流れはサードパーティのライブラリを使用しています: - https://github.com/orazz/CalendarPopUp –

+0

@JayprakashSingh開始日と終了日を使用できると思います –

+0

はい使用開始日と終了日 –

関連する問題