我不能告诉你的Objective-C,iOS或uipickerview ...对于算法什么。这里是特别没有语言的一些伪代码:
i = 7 // this is i in your example
offset=420 // This is where you could say you want
// to start at 7:00 (420 minutes after midnight)
// you could use any number here obviously.
counter = offset
while (counter<1440+offset){
counter = counter+i
minutes = counter%60
hours = counter/60 // Use integer division
}
的模二向你分给你,其余每一次。所以在你的榜样分钟将从56去=> 63 => 3,其你想要什么。
,如果你只是想知道分钟和小时会是怎样一个给定的时间间隔(假设间隔去从0到206(有一天206个7分钟间隔),那么你会做以下几点:
minutes = (i*intervalNum) % 60
hours = (i*intervalNum)/60 // Integer division!
如果你需要在一个时间间隔的号码,你可以做到以下几点:
keep a hashmap (again I don't know how objective-c handles these) that maps an hour to a list of the minutes that mark intervals. In your example you could have a hashmap that looks like:
{0 => (0,7,14,21,28,35,42,49,56),
1 => (3,10,17,24,31,38,45,52,59),
2 => (6,13,20,27,34,41,48,55),
...
}
第一轮通过过程中,您将建立这个地图获得2-间隔数。 3时隙只是返回地图[2] .length(或任何其等价物)。
很明显,这是许多方法之一,并需要更多的上下文来进一步细节。
好运
这确实让我指出了正确的方向。但有一点是,如何获得特定时间段的分钟数?在我的屏幕截图中,他们都有8-7分钟的间隔,除了最后一个间隔为7-7分钟。 – Bot
看我上面的编辑。 – ajon