问题标签 [nsdatepicker]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
63 浏览

ios - 从 NSDatePicker 添加声音以在时间播放

我正在创建一个项目,该项目要求用户能够设置声音以在特定时间播放,而我目前正在使用本地通知来执行此操作。我想将其更改为使用AVAudioPlayer,我想知道,最好的方法是什么?

我现在得到的对象是一个NSDatePicker和一个stringFromDate字符串。我的目标是创建一个闹钟,以便用户可以使用 设置时间NSDatePicker,届时声音会响起。

0 投票
2 回答
3970 浏览

swift - 从 NSDatePicker 获取小时和分钟 - Swift

嗨,所以我做了一些事情,用户在 NSDatePicker 中输入时间,这样我就可以获取值并将其存储到字符串中以供以后使用。我已经将日期选择器与插座连接起来,我试图在没有运气的情况下获得导出的价值!请帮忙!

NSDatePicker 设置为仅显示像这样的时间 12:00 am

谢谢

0 投票
2 回答
114 浏览

ios - 如何从 NSDatePicker 获取音频播放时间?

我正在制作一个应用程序,该应用程序需要在用户设置的未来某个时间播放声音,NSDatePicker我该怎么做?

我已经有了AVAudioPlayer设置,我只需要播放本身的帮助。请写下如何做到这一点,以回答整个问题,而不是把我带到别处。

目的是获得一个警报,用户可以在特定时间使用NSDatePicker和使用我制作并添加到项目中的声音来设置警报。然后用户必须关闭警报本身而不是自动关闭。所以我打算使用AVAudioPlayer一个关闭按钮来这样做,但我无法超越时间。

0 投票
2 回答
188 浏览

swift - 如何在 NSDatePicker 图形模式下设置颜色

我有一个包含创建时间的文件列表,我想在 NSDataPickerView 中将其显示为不同的颜色。像这样我怎样才能做到这一点?我试过self.datePicker.textColor = NSColor.redColor()了,但它不起作用。

0 投票
1 回答
36 浏览

ios - Comparing dates in loop, then adding interval?

I've been really stuck on this one for a while. The user will set a custom alarm interval and then pick a date on the picker, and the app is set to display the next alarm. If they set it in the past, I want the app to add the interval by looping until it is in the future.

I've been playing around with the date comparisons but I can't seem to get anything to work. How would you guys accomplish this? Thanks!

0 投票
1 回答
328 浏览

cocoa - Show Day and Date in NSDatePicker

I am trying to do something that would seem to be very simple and surprised to find no help or similar postings anywhere.

I want an NSDatePicker, which I have setup in IB and bound to property, to display as full day and date like so:

Sunday, March 6 2016

I tried dropping a NSFormatter on the Date Picker Cell, it seems to have no effect. No matter the settings, it always displays as:

3/12/2016

After a good deal of searching, I am about to set up a complex sequence of showing and hiding the control to use a NSTextfield to display in its place. The idea being that the NSDatePicker will become visible for editing only. I am sure that will work, it just seems so much trouble for no reason.

Is it possible to alter the formatting on the NSDatePicker when it is not firstResponder? Understanding that it needs to display in the default manner when editing, I just want it to display more like a label when not firstResponder.

0 投票
0 回答
154 浏览

cocoa - 如何从 NSDatePicker 设置/获取选择元素

我试图找到一种方法来设置/获取选定的元素NSDatePicker

例如,如果NSDatePicker在选定的元素后面有一个类似的元素是年份。

NSD 日期选择器

我想知道哪个是选定元素,并想通过编码更改选定元素。我只能通过鼠标单击或键盘箭头来更改选择。

有人知道吗?

顺便说一句,macOS 日历应用程序和 Fantastical2 应用程序可以做到这一点,这意味着必须有一种方法可以在不使用私有 API 的情况下做到这一点。

0 投票
1 回答
994 浏览

swift - NSStatusBar NSSMenuItem 中的 NSDatePicker 未接收输入

不久前,我编写了一个名为Day-O的简单日历菜单栏小部件。日历使用在添加到 NSStatusItem 的 NSMenu 中的 NSMenuItem 内的 NSView 内嵌套的股票 NSDatePicker。该应用程序的activationPolicy 为.accessory(最初通过plist 的“应用程序是代理”布尔设置)。在某些时候(可能是 El Capitan 更新?)日历停止响应输入。当应用程序首次启动时,您可以单击状态栏项以展开菜单并与日历交互,它会按预期响应用户输入。但是一旦应用程序失去了初始焦点,日历就会停止响应输入。

我想我已经将问题追溯到最初退出活动后未激活的应用程序。问题是,如果我在单击(使用)菜单栏项时尝试手动激活应用程序,则NSApp.activate(ignoringOtherApps:true)菜单(您刚刚打开)将被关闭。

我也试过告诉窗口让 NSDatePicker 成为第一响应者,但这似乎也没有任何效果。

当状态栏应用程序不是活动应用程序时,如何在菜单项中获取 NSDatePicker 以接受用户输入?


编辑:说明问题的最简单代码(将其添加到新的 macOS Cocoa 应用程序中的 AppDelegate):

启动应用程序,单击菜单项,然后单击日历周围。然后单击另一个应用程序,然后再次单击菜单项。日历不再响应点击。

0 投票
0 回答
169 浏览

swift - NSDatePicker 设置日颜色

我在我的应用程序中使用 NSDatePicker。如何设置 10 月 15 日和 21 日的绿色和 10 月 17 日的橙色?

NSD 日期选择器

0 投票
0 回答
70 浏览

objective-c - 为什么我的代码只能在第二次工作?委托问题?

在 Objective-C 中,我试图创建一个 NSTextField,单击时打开一个带有 NSDatePicker 的工作表,该工作表在文本字段下滑出。您选择一个关闭工作表并使用所选日期填充 NSTextField 的日期。

我找到了这篇关于如何在 Swift 中使用协议来执行此操作的文章。 http://www.knowstack.com/swift-nsdatepicker-sample-code/#comment-20440

但是当我将它转换为 Objective-C 时,我遇到了一些问题。

第一次单击按钮触发工作表时,工作表出现在屏幕中间,忽略事件:

当我选择一个日期时,主 xib 中的文本字段会根据选择进行更新,因此协议部分正在工作,但工作表在屏幕上仍然没有响应。

如果我再次单击该按钮,则无响应的工作表将关闭并重新出现在 NSTextField 下,并在我选择日期时自行消失。这是预期的行为。

我的问题是,为什么这在我第一次单击按钮时不起作用,但仅在第二次起作用?

这是代码:




我假设我让代表搞砸了。也许在 xib 或代码中。我不明白为什么它会第二次起作用。这是由于保留还是我如何保留 DatePicker。

非常感谢您的帮助。