根据维基百科...单调函数是一个增加或减少的函数..如果一个函数正在增加和减少,那么它不是单调函数或它的反单调函数.
但根据我正在阅读的数据挖掘书,它表示如果一个集合不常见,那么反单调属性,那么它的所有超集都很少见.
根据维基百科,这个属性看起来不像单调吗?
有人可以解释一下这两者有什么区别?
我正在尝试为标签文本设置动画,以便如果值较大,它将文本颜色更改为蓝色,如果值较小,则将颜色更改为红色,否则保持相同的“黑色”。
但是UIView.animateWithDuration()它将颜色永久更改为蓝色,我想要做的就是如果值大于或小于,我想将标签颜色更改为蓝色或红色几秒钟,然后将其颜色恢复为黑色。
这是我的代码:
@IBOutlet weak var label: UILabel!
let x = 10
let y = 20
if x > y
{
UIView.animateWithDuration(2,animations:
{ () -> Void in self.label.textColor = UIColor.blueColor(); })
}
else if y < x
{
UIView.animateWithDuration(2,animations:
{ () -> Void in self.label.textColor = UIColor.redColor(); })
}
else
{
self.label.textColor = UIColor.blackColor()
}
Run Code Online (Sandbox Code Playgroud)
我也尝试使用如下Sleep功能,但没有成功
self.label.textColor = UIColor.blueColor()
sleep(3)
self.label.textColor = UIColor.blackColor()
Run Code Online (Sandbox Code Playgroud) 我正在尝试进行自定义系统调用.
我的系统调用需要2个参数struct buffer **mybuffer&int size.
它会强加任何**mybuffer应该反映在用户空间中的变化,但似乎它不起作用.
所以我在其他地方看到过我可以copy_to_user(void *dest, void *src, int size)用来将数据从内核空间复制到用户空间.
在用户空间中,我有一个名为buffer的结构,此结构在系统调用中也是相同的.
typedef struct buffer {
int n;
}buffer;
int main(void)
{
buffer **buf = malloc(sizeof(buffer *));
int i = 0
for(;i<8;i++)
buf[i] = malloc(sizeof(buffer));
long int sys = systemcall(801,buf,8)
//print out buf
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在系统调用我有
asmlinkage long sys_something(buffer **buf,int size)
{
//allocate buffer same as it appears in int main
//fill buf with some data
for(i = 0; i<size,i++) …Run Code Online (Sandbox Code Playgroud) 我已成功在索引处滚动项目,例如,如果用户点击按钮,则转到最后一项
这是我用过的代码
self.collection.scrollToItemAtIndexPath(NSIndexPath(forItem: self.array.count - 1, inSection: 0), atScrollPosition: UICollectionViewScrollPosition.Top, animated: true)
Run Code Online (Sandbox Code Playgroud)
但我的问题是如何知道用户是在底部还是在顶部UICollectionView?
我可以通过创建2个函数来做到这一点,如果用户点击TOP UIButton它会上升,反之亦然......
但我只想用一个单一的方式做到这一点UIButton.因此,如果用户按下按钮,代码应该知道用户是否在底部并且向上,反之亦然.我查看了每个函数,UICollectionView但似乎没有return用户在哪个项目.
我想到了一些在逻辑上可能正确的东西
var someBool: Bool!
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let tempIndex: Int = self.array.count / 2
if indexPath.row > tempIndex{
someBool = true // UP
} else {
someBool = false // Down
}
...
}
@IBAction func buttonPressed{
if someBool{
self.collection.scrollToItemAtIndexPath(NSIndexPath(forItem: 0, inSection: 0), atScrollPosition: UICollectionViewScrollPosition.Top, animated: true)
} else { …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个应用程序来选择多个单元格,所以让我们假设我们有9个单元格从0到8的索引.
这是我想要做的......
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
var cell = collectionView.cellForItemAtIndexPath(indexPath)
if cell?.selected == true {
cell?.backgroundColor = UIColor.orangeColor()
}
}
Run Code Online (Sandbox Code Playgroud)
并取消选择Func()
func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath) {
var cell = collectionView.cellForItemAtIndexPath(indexPath)
cell?.backgroundColor = UIColor.clearColor()
}
Run Code Online (Sandbox Code Playgroud)
如果用户选择一个单元格就足够了 - >如果取消选择单元格则为> orange - > clearColor'white'所以这个代码工作正常
如果用户选择单元格0,它也会更改单元格6的颜色,"请记住,单元格6未被选中,只需更改它的外观".对于单元格1,如果它选择了单元格7更改等等,同样如果我取消选择单元格0或单元格6两个更改.
所以我试过cell?.selected == true,UICollectionView.allowsMultipleSelection = true这两个属性都不适合我.
难道我做错了什么 ?
这是与Cell Reuse有关的问题吗?如果是这样你能解释这种行为吗?
swift ×3
xcode ×2
c ×1
data-mining ×1
ios ×1
linux ×1
linux-kernel ×1
system-calls ×1
uilabel ×1