我尝试使用jquery $(this)选择器和元素的类来计算div中的子节点数.结果不同.我认为jquery是$(this)指函数的所有者对象,有什么特别的东西$(this)我错过了吗?
$('.parent').ready(function(){
$('.parent').children().length; // 6
$(this).children().length; // 1
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试为iPhone定制UIImagePickerController.我可以修改默认按钮(取消和取消)以及添加更多按钮.但是在尝试使自定义按钮看起来像默认的iPhone时,我遇到了麻烦.首先,我认为如果我通过以下代码获取然后克隆默认按钮作为我的模板是可能的
UIButton *cancelButton = [[[[[[[[[[[[[[[[self.view subviews] objectAtIndex:0]
subviews] objectAtIndex:0]
subviews] objectAtIndex:0]
subviews] objectAtIndex:0]
subviews] objectAtIndex:2]
subviews] objectAtIndex:0]
subviews] objectAtIndex:1]
subviews] objectAtIndex:1];
UIButton *anotherButton = [cancelButton copy];
Run Code Online (Sandbox Code Playgroud)
但由于我最近才知道NSObject及其子类默认情况下不实现NSCopying协议,所以它没有用.
我想知道有没有办法 - 复制一个UI元素,然后按照我的意愿修改它 - 创建一个带有Apple的外观的自定义按钮