selector

Unrecognized selector with UITapGestureRecognizer

邮差的信 提交于 2019-12-02 08:41:11
I'm trying to add in my app the possibility to dismiss the keyboard when the user taps somewhere else out of the text fields. I'm implementing this functionality using UITapGestureRecognizer. I create a new UITapGestureRecognizer object using the Unrecognized selector with UITapGestureRecognizer(target: Any?, action: Selector?) and set the action parameter to a function that resigns the first responder of both the text fields I'm using in this view. I set everything properly adding the keyword @objc before the method I pass as action and using the #selector(dismissKeyboard) form, but when I

How can I get values of inputs that have the same class using JQuery each?

两盒软妹~` 提交于 2019-12-02 08:37:21
This should be easy, but I can't seem to get it right. var totalHours = 0; this.$(".timesheet-daily-input").each( function () { var inputValue = $(this).text(); var hours = parseInt(inputValue); totalHours += (hours == null) ? 0 : hours; }); I've tried $(this).val() and $(this).html() as well, but can't get the values out of the input fields. Edit: Apologies, I knew I was forgetting to mention something. The "this." at the start of the each loop is because I am using backbone's models and collections. The first "this." refers to the specific model in question. It loops through the proper

Mac OS, console application. performSelector:withObject:afterDelay: doesn't work?

拟墨画扇 提交于 2019-12-02 08:36:13
I created a simple singleton and run method in it: - (void)run { static int times = 0; NSLog(@"times = %d", times++); [self performSelector:@selector(run) withObject:nil afterDelay:MIN_DELAY]; } But it doesn't work properly. It is executed only once. But if I replace performSelector:withObject:afterDelay: with performSelector: then it will be called a lot of times (but I need a delay between calls). So why method performSelector:withObject:afterDelay: doesn't work? And can I use this method at all? Calls to -performSelector:withObject:afterDelay: require a run loop. Console applications do not

Copy div from parent website to a textarea in iframe

别说谁变了你拦得住时间么 提交于 2019-12-02 08:28:42
In the Google Translator I've made a second instance of Google Translate with var makediv = document.createElement("secondinstance"); makediv.innerHTML = '<iframe id="iframenaturalID" width="1500" height="300" src="https://translate.google.com"></iframe>'; makediv.setAttribute("id", "iframeID"); var getRef = document.getElementById("gt-c"); var parentDiv = getRef.parentNode; parentDiv.insertBefore(makediv, getRef); And I'm trying to copy text from auto-correction of the first instance to the textarea of the second instance: I'm trying this (this code works if I just copy html within the Chrome

Pass parameter on selector of UIButton

与世无争的帅哥 提交于 2019-12-02 08:17:37
问题 I have a detailDisclousure button on the callout of a MKAnnotation . When this button is pressed I need to call a method passing a parameter that identifies the annotation that called it. How could it be done? this is my viewForAnnotation: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { if ([annotation isKindOfClass:[Annotation class]]) { static NSString* identifier = @"identifier"; MKPinAnnotationView* pinView = (MKPinAnnotationView*)

How to only select text outside of a tag in jQuery

萝らか妹 提交于 2019-12-02 08:15:43
I'm trying to implement a text-highlighting search script on a Wordpress site for a client. The script executes a regex search on the raw HTML data from the webpage, adding a span tag/css element to any part of the document that matches the query. However, I'm trying to search on some multi-level HTML (headers, etc), and some of the tags have descriptive id and class names, which actually end up getting found by the script and highlighted. This results in some wonky behavior when the script finds a match in one of the id names (ex: a search for "Cont" would wrap turn <div id="Container"> into

Android EditText native selector

随声附和 提交于 2019-12-02 06:19:16
问题 I try to apply my own design to edittext and to use android native selector when my edittext is enabled, focused, etc. The problem is that every time I touch the edittext and the native selector is working my edittext becomes smaller. Can anyone please suggest why this is happening?Here is my code snippet: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@android:drawable/edit_text"/

Using NSUserDefaults for storing UISwitch state

爱⌒轻易说出口 提交于 2019-12-02 04:47:42
I am trying to persist the UISwitch state in my settings view of my application. Basically it is a UITableView and contains a few switches to get the user preferences. The below code explains how the switches are constructed (only one switch construct is given below, others are also constructed the sameway). if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SomeIdentifierB] autorelease]; if (syncStartupSwitch) { syncSwitch.on = YES; }else { syncSwitch.on = NO; } [syncSwitch addTarget:self action:@selector(syncAtStartup:) forControlEvents

How to test if a UIControlEvents has been fired

不问归期 提交于 2019-12-02 03:47:31
问题 I have a library implementing a custom UIControl with a method which would fire a .valueChanged event when called. I would like to test the method for that behavior. My custom control: class MyControl: UIControl { func fire() { sendActions(for: .valueChanged) } } And the test: import XCTest class ControlEventObserver: NSObject { var expectation: XCTestExpectation! init(expectation anExpectation: XCTestExpectation) { expectation = anExpectation } func observe() { expectation.fulfill() } }

A dynamic method name (Objective-C)

你说的曾经没有我的故事 提交于 2019-12-02 03:46:16
问题 I have several methods, like below: - (void)methodA; - (void)methodB; - (void)methodC; and they are used depending on some conditions. Now I want to dynamically use them, and I tried this: NSString *methodName; if(_flag == A) methodName = @"methodA"; else if (_flag == b) methodName = @"methodB"; else methodName = @"methodC"; [self performSelector:@selector(methodName)]; but it seems wrong. So how should I use a dynamic method name for a given receiver depending on different situations? Thanks