cocoa-touch

UITextField “value changed” not firing when field is updated

杀马特。学长 韩版系。学妹 提交于 2019-12-31 10:57:27
问题 I have an IBAction that I have connected to a UITextField element in Interface Builder. (Firing on "value changed" event) I also have a UISlider that updates the TextField element automatically when it's value gets adjusted. When I run my app, the TextField does get updated when I adjust the slider, but the "value changed" event does not fire when this happens. The value changed event also does not fire when I edit the TextField by hand as well. (Although using the Did Editing End trigger

NSDictionary Key For Value/Object? [duplicate]

我怕爱的太早我们不能终老 提交于 2019-12-31 10:56:11
问题 This question already has answers here : How to get the key for a given object from an NSMutableDictionary? (4 answers) Closed last month . Can we get the key for an object in an NSDictionary by passing a particular value or object? 回答1: -[NSDictionary allKeysForObject:] returns an NSArray of all the keys whose objects match the passed object, where "match" is determined by isEqual: . 回答2: To answer you question in a more specific manner, use the following to get a key for a particular object

locationServicesEnabled always return YES

若如初见. 提交于 2019-12-31 10:45:26
问题 I tested my device (iPod Touch 2G iOS 4.1) if location services are enabled permitted = [locationManager locationServicesEnabled]; and I always get a YES whether location services are enabled or not. I'm talking about the general button for location services and not the app specific button. On iPad with iOS 3.2.2 everything is working fine. 回答1: When you implement the delegate for location manager, you should be implementing didFailWithError. In there you will get the appropriate error if the

How to print or see method call stack in xcode?

妖精的绣舞 提交于 2019-12-31 09:45:16
问题 I working on my iPad App, While running the code there is one method in table view. as we know `cellForRowAtIndexPath:` There are several times this method can be called. like while scrolling table view cells. Or table view reload data. I have complex coding so I just want to see method call stack... That from which method is calling cell for row at index path. I have used NSLogs and breakpoints but still could not get. 回答1: When you hit a breakpoint, select the Debug navigator in the

Next/Previous Keyboard Toolbar iOS7

本小妞迷上赌 提交于 2019-12-31 08:57:17
问题 Currently, I am trying to set the next/previous buttons on my keyboard toolbar to the new, sleek iOS 7 back button/forward buttons that get put in navigation controllers to go back. Here is what I am trying. How can I use the system bar button item instead of the boring static text? [self setToolbar:[[UIToolbar alloc] initWithFrame:self.frame]]; [self.toolbar setBarStyle:UIBarStyleDefault]; [self.toolbar setAutoresizingMask:(UIViewAutoresizingFlexibleLeftMargin |

Detect a shake in iOS Safari with Javascript?

霸气de小男生 提交于 2019-12-31 08:39:12
问题 How can I utilize the new MobileSafari device motion APIs to capture a "shake" event? 回答1: See this awesome blog post: http://www.jeffreyharrell.com/blog/2010/11/creating-a-shake-event-in-mobile-safari/ Which illustrates this example: if (typeof window.DeviceMotionEvent != 'undefined') { // Shake sensitivity (a lower number is more) var sensitivity = 20; // Position variables var x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0; // Listen to motion events and update the position window

how to dismiss a modal view controller presented as “Form Sheet” when a touch occur outside the form sheet?

我与影子孤独终老i 提交于 2019-12-31 08:31:55
问题 I have a View Controller (with a UIWebView) i present in Form Sheet style. I have to put a "Done" button in the UIToolbar of the view in the View Controller to have it dismissed. But, since presenting it in "Form Sheet" style leaves plenty of unused space outside the View Controller's view... I was wandering.. Is there a way to detect a touch outside the View? in that "grayed out" area? Thanks in advance 回答1: On iOS 4.2, the view hierarchy of a Navigation Controller based app with a modal

How to get a single NSString character from an NSString

旧城冷巷雨未停 提交于 2019-12-31 08:30:38
问题 I want to get a character from somewhere inside an NSString. I want the result to be an NSString. This is the code I use to get a single character at index it: [[s substringToIndex:i] substringToIndex:1] Is there a better way to do it? 回答1: This will also retrieve a character at index i as an NSString, and you're only using an NSRange struct rather than an extra NSString. NSString * newString = [s substringWithRange:NSMakeRange(i, 1)]; 回答2: If you just want to get one character from an a

how to dismiss a modal view controller presented as “Form Sheet” when a touch occur outside the form sheet?

眉间皱痕 提交于 2019-12-31 08:30:12
问题 I have a View Controller (with a UIWebView) i present in Form Sheet style. I have to put a "Done" button in the UIToolbar of the view in the View Controller to have it dismissed. But, since presenting it in "Form Sheet" style leaves plenty of unused space outside the View Controller's view... I was wandering.. Is there a way to detect a touch outside the View? in that "grayed out" area? Thanks in advance 回答1: On iOS 4.2, the view hierarchy of a Navigation Controller based app with a modal

How to animate layer shadowOpacity?

自作多情 提交于 2019-12-31 08:25:32
问题 I have a view on which I've set the layerOpacity to 1. theView.layer.shadowOpacity = 1.0; This looks fine when the view is farther down the screen. When I move this view up to be flush with another view that has a shadow, they don't look good. Is there a way I can animate the shadowOpacity on my layer to be 0? I tried using an animation block but it seems as if this property is not animatable. EDIT: Request for code that doesn't work: [UIView animateWithDuration:1.0 animations:^{ splitView2