首页
\
问答
\
我可以使用Jquery来查找元素并将它的CSS宽度设置为current-width-x?(Can I use Jquery to find an element and set it's CSS width to current-width - x?)
我可以使用Jquery来查找元素并将它的CSS宽度设置为current-width-x?(Can I use Jquery to find an element and set it's CSS width to current-width - x?)
假设我需要将一些元素宽度修正为19px。
是否有可能
find
元素并设置找到的元素CSS宽度如下所示:$el.find( '.ui-content' ) .css({'width': "parseFloat(found_element_current_width) -19" })
如果不是,那么做到这一点的最好方法是什么?
Say I need to correct a number of elements widths by 19px.
Is it possible to
find
elements and set the found elements CSS-width like so:$el.find( '.ui-content' ) .css({'width': "parseFloat(found_element_current_width) -19" })
If not, what's the best way to do this?
原文:https://stackoverflow.com/questions/12913621
更新时间:2021-09-28 07:09
最满意答案
问题出在我认为的这个问题上:
let existingContact: ABRecord! = ABAddressBookGetPersonWithRecordID(adbk, recordID).takeRetainedValue()
我改变了我的功能,现在它使用
ABRecord
而不是ABRecordID
来访问所需的记录。固定代码:
if doesPersonExistWithFirstName(firstName: "Call Recorder", inAddressBook: adbk) { var success: Bool = false let phoneNumbers: ABMutableMultiValue = ABMultiValueCreateMutable(ABPropertyType(kABMultiStringPropertyType)).takeRetainedValue() var error: Unmanaged<CFError>? = nil success = ABMultiValueAddValueAndLabel(phoneNumbers, recordServicePhoneNumber!, kABPersonPhoneMainLabel, nil) print("setting phone number successful? \(success)") success = ABRecordSetValue(existingContact, kABPersonPhoneProperty, phoneNumbers, &error) print("adding phone numbers successful? \(success)") success = ABAddressBookAddRecord(adbk, existingContact, &error) print("Adbk addRecord successful? \(success)") success = ABAddressBookSave(adbk, &error) print("Adbk Save successful? \(success)") } else { let newContact: ABRecord! = ABPersonCreate().takeRetainedValue() var success: Bool = false let newFirstName: NSString = "Call Recorder" let image: UIImage = UIImage(named: "record")! let imageData = UIImagePNGRepresentation(image) let phoneNumbers: ABMutableMultiValue = ABMultiValueCreateMutable(ABPropertyType(kABMultiStringPropertyType)).takeRetainedValue() var error: Unmanaged<CFError>? = nil success = ABRecordSetValue(newContact, kABPersonFirstNameProperty, newFirstName as CFTypeRef, &error) print("setting first name was successful? \(success)") success = ABMultiValueAddValueAndLabel(phoneNumbers, recordServicePhoneNumber!, kABPersonPhoneMainLabel, nil) print("setting phone number successful? \(success)") success = ABPersonSetImageData(newContact, imageData as CFData!, &error) print("setting image successful? \(success)") success = ABRecordSetValue(newContact, kABPersonPhoneProperty, phoneNumbers, &error) print("adding phone numbers successful? \(success)") success = ABAddressBookAddRecord(adbk, newContact, &error) print("Adbk addRecord successful? \(success)") success = ABAddressBookSave(adbk, &error) print("Adbk Save successful? \(success)") }
existingContacts
实现:var existingContact: ABRecord! = ABPersonCreate().takeRetainedValue() func doesPersonExistWithFirstName(firstName paramFirstName: String, inAddressBook addressBook: ABAddressBook) -> Bool { let people = ABAddressBookCopyArrayOfAllPeople(addressBook).takeRetainedValue() as NSArray as [ABRecord] for person: ABRecord in people { let firstName = ABRecordCopyValue(person, kABPersonFirstNameProperty).takeRetainedValue() as! String if firstName == paramFirstName { existingContact = person return true } } return false }
The problem was in this line as I thought:
let existingContact: ABRecord! = ABAddressBookGetPersonWithRecordID(adbk, recordID).takeRetainedValue()
I changed my function so now it uses
ABRecord
instead ofABRecordID
to access required record.Fixed code:
if doesPersonExistWithFirstName(firstName: "Call Recorder", inAddressBook: adbk) { var success: Bool = false let phoneNumbers: ABMutableMultiValue = ABMultiValueCreateMutable(ABPropertyType(kABMultiStringPropertyType)).takeRetainedValue() var error: Unmanaged<CFError>? = nil success = ABMultiValueAddValueAndLabel(phoneNumbers, recordServicePhoneNumber!, kABPersonPhoneMainLabel, nil) print("setting phone number successful? \(success)") success = ABRecordSetValue(existingContact, kABPersonPhoneProperty, phoneNumbers, &error) print("adding phone numbers successful? \(success)") success = ABAddressBookAddRecord(adbk, existingContact, &error) print("Adbk addRecord successful? \(success)") success = ABAddressBookSave(adbk, &error) print("Adbk Save successful? \(success)") } else { let newContact: ABRecord! = ABPersonCreate().takeRetainedValue() var success: Bool = false let newFirstName: NSString = "Call Recorder" let image: UIImage = UIImage(named: "record")! let imageData = UIImagePNGRepresentation(image) let phoneNumbers: ABMutableMultiValue = ABMultiValueCreateMutable(ABPropertyType(kABMultiStringPropertyType)).takeRetainedValue() var error: Unmanaged<CFError>? = nil success = ABRecordSetValue(newContact, kABPersonFirstNameProperty, newFirstName as CFTypeRef, &error) print("setting first name was successful? \(success)") success = ABMultiValueAddValueAndLabel(phoneNumbers, recordServicePhoneNumber!, kABPersonPhoneMainLabel, nil) print("setting phone number successful? \(success)") success = ABPersonSetImageData(newContact, imageData as CFData!, &error) print("setting image successful? \(success)") success = ABRecordSetValue(newContact, kABPersonPhoneProperty, phoneNumbers, &error) print("adding phone numbers successful? \(success)") success = ABAddressBookAddRecord(adbk, newContact, &error) print("Adbk addRecord successful? \(success)") success = ABAddressBookSave(adbk, &error) print("Adbk Save successful? \(success)") }
existingContacts
implementation:var existingContact: ABRecord! = ABPersonCreate().takeRetainedValue() func doesPersonExistWithFirstName(firstName paramFirstName: String, inAddressBook addressBook: ABAddressBook) -> Bool { let people = ABAddressBookCopyArrayOfAllPeople(addressBook).takeRetainedValue() as NSArray as [ABRecord] for person: ABRecord in people { let firstName = ABRecordCopyValue(person, kABPersonFirstNameProperty).takeRetainedValue() as! String if firstName == paramFirstName { existingContact = person return true } } return false }
相关问答
更多-
AB框架有时可能是一个真正的痛苦。 但它分解为一系列非常简单的操作。 首先,你必须创建一个ABAddressBook实例: ABAddressBookRef addressbook = ABAddressBookCreate(); 然后,您需要制作地址簿中所有人员的数组副本,并逐步查找所需的数据: CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressbook); CFIndex numPeople = ABAddressBookG ...
-
使用NSPredicate for iOS从ABAddressBook搜索联系人姓名(Search Contact name from ABAddressBook using NSPredicate for iOS)[2023-07-11]
你可以这样做: NSArray *allPeople = CFBridgingRelease(ABAddressBookCopyArrayOfAllPeople(addressBook)); NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id person, NSDictionary *bindings) { NSString *firstName = CFBridgingRelease(ABRecordCopyValu ... -
在ABAddressBook中获取重复的电话号码时提高性能(Improve performance when getting duplicate phone numbers in ABAddressBook)[2021-08-18]
我没有时间检查两者之间的时间,但我确实注意到你在地址簿号码上多次迭代(对于每个电话号码,你再次在列表中迭代每个.Where)。 另外我注意到你在循环中多次为每个电话号码执行相同的正则表达式。 这可能不完全符合您的需求,但它确实在我的地址簿中找到了重复项并且速度不是很慢。 ABAddressBook ab = new ABAddressBook(); // flatten out the list of all phone numbers and perform the regEx just once fo ... -
问题出在我认为的这个问题上: let existingContact: ABRecord! = ABAddressBookGetPersonWithRecordID(adbk, recordID).takeRetainedValue() 我改变了我的功能,现在它使用ABRecord而不是ABRecordID来访问所需的记录。 固定代码: if doesPersonExistWithFirstName(firstName: "Call Recorder", inAddressBook: adbk) ...
-
在iOS 4+中从ABAddressBook获取特定的ABSource(Obtaining Specific ABSource from ABAddressBook in iOS 4+)[2023-06-17]
iOS 4+提供了新的API,允许从ABAddressBook中选择特定的ABSource。 这可能是有用的,因为某些操作(例如创建ABGroup)在某些源(例如Exchange)中不受支持。 “不是所有的源类型都支持组,更明显的是,Exchange不知道任何关于组的信息。” - http://flavors.me/volonbolon#1a5/tumblr 附加的功能利用新API获取可用于调用ABGroupCreateInSource()的特定类型的源。 #define CFRELEASE_AND_NIL ... -
是否有可能在iOS中创建临时ABAddressBook数据库?(Is it possible to create a temporary ABAddressBook Database in iOS?)[2022-08-23]
我一直在玩这个想法,但这是不可能的。 只要您创建地址实例,它也会显示在“普通”地址簿中。 I have been playing around the idea as well, but it is not possible. As soon as you create address instance, it will be displayed in the "normal" address book as well. -
如何从地址簿ios以编程方式编辑电话号码值(how to edit a phone number values programmatically from address book ios)[2023-03-28]
您应该调试代码并尝试确定您为方法提供的电话号码的格式是否匹配。 例如,当我记录我的联系人列表电话号码时,这些都是结果 Number...555-478-7672 Number...(408) 439-5270 Number...(408) 555-3514 Number...888-555-5512 Number...888-555-1212 Number...555-522-8243 Number...(555) 766-4823 Number...(707) 555-1854 Number...555- ... -
在ABAddressBook - iPhone中为现有ABRecord添加新号码(adding a new number to existing ABRecord in ABAddressBook - iPhone)[2022-12-12]
今天早上进一步了解API后我找到了解决方案。 干得好: // contactId is the ID of the person i need to add a new number to his contacts // got the id through : ABRecordGetRecordID( ABRecordRef ) ABRecordRef person = ABAddressBookGetPersonWithRecordID(lAddressBook, contactID); ABMutab ... -
不,这是不可能的。 您无法使用tel URL拨打iPhone或* # 。 Apple在Apple URL Scheme Reference中记录了对tel URL的支持,其中说明了这一点: 具体来说,如果URL包含*或#字符,则Phone应用程序不会尝试拨打相应的电话号码。 No, it is not possible. You cannot make the iPhone dial a * or a # using a tel URL. Apple documents its support for te ...
-
如果您无法优化程序,您也可以为加载分叉一个新线程,然后应用程序可以继续加载并对用户进行响应。 [NSThread detachNewThreadSelector:@selector(_loadContactsInAnotherThread:) toTarget:self withObject:self]; -(void)loadContactsInAnotherThread:(void *)obj { NSLog("Do time intensive stuff here."); } If y ...