2016-11-01 18 views
1

DateTimeRow()の開始時刻を設定しようとしています。その日付をクリックするたびに、DateTimeピッカー時間は午前7時30分に回転します。Eureka DateTimeRowを特定の時間に設定します。

timePicker.setDate([My Date here], animated: true) 

Display Text label is update while the date picker is not

次のコードは、唯一の日付ピッカー回転していない間、表示テキストを変更している:のような

row = DateTimeRow() { 
    $0.minuteInterval = 30 
}.onCellSelection({(cell,row) in 
    if row.baseCell.detailTextLabel?.text == nil { 

    // Setup the start date 
    var currentDate = NSDate() as Date 
    currentDate = currentDate.setHoursMinutes(hour: 7, minute: 30) 
    let dateFormatter = DateFormatter() 
    dateFormatter.timeStyle = .short 
    dateFormatter.dateStyle = .short 
    dateFormatter.locale = NSLocale.current 

    // This will show the current day date with time of 7:30 AM 
    row.baseCell.detailTextLabel?.text = dateFormatter.string(from: currentDate) 
} 

を直接ピッカーにアクセスする方法はありますし、呼び出しSETDATE

ありがとう

+0

はい、この関数を呼び出すと、ピッカーが表示されたときに、それがスクロールしますしたいですダあなたが設定した、アニメーションかどうかで。 –

+0

ありがとうございます。添付の​​画像でわかるように、表示テキストが変更されている間は日付ピッカーはスクロールされません –

+0

datepickerビューを表示する前にこの関数を呼び出しましたか? –

答えて

1

私はしていたあなたの日付の値は、この

<<< DateTimeRow() { 
      var currentDate = Date() 
      currentDate = currentDate.setHoursMinutes(hour: 7, minute: 30) 
      $0.value = currentDate 
      } 

か、cellSetupコールバックを使用する必要があるようなセルの作成何かに私はあなたがセットアップが必要だと思いますがonCellSelectionコールバックであなたのセルを設定しているすべての最初の、あなたの質問にrking、および場合私はこれがあなたの役に立てば幸いあなたはonCellSelectionコールバックに

<<< DateTimeRow().cellSetup({ (dateCell, dateTimeRow) in 
         // Setup the start date 
         let currentDate = Date() 
         currentDate = currentDate.setHoursMinutes(hour: 7, minute: 30) 
         dateTimeRow.dateFormatter?.dateStyle = .short 
         dateTimeRow.dateFormatter?.timeStyle = .short 
         //dateFormatter.locale = NSLocale.current 
         dateCell.row.value = currentDate 
      }).onCellSelection({ (cell, row) in 
       //If you want to show different date 
       let currentDate = NSDate() as Date 
       currentDate.setHoursMinutes(hour: 9, minute: 30)  
       cell.datePicker.date = currentDate 
      }) 

を実装する必要がありますし、別のdateTimeを示し、よろしく

関連する問題