UILabel UITextField UITextView

UILabel: “The UILabel class implements a read-only text view.” UITextField: “A UITextField object is a control that displays editable text and sends an action message to a target object when the user presses the return button.” UITextView: “The UITextView class implements the behavior for a scrollable, multiline text region.” So: labels are read-only textfields are … Read more

How can I tell a UIGestureRecognizer to cancel an existing touch?

This little trick works for me. @implementation UIGestureRecognizer (Cancel) – (void)cancel { self.enabled = NO; self.enabled = YES; } @end From the UIGestureRecognizer @enabled documentation: Disables a gesture recognizers so it does not receive touches. The default value is YES. If you change this property to NO while a gesture recognizer is currently recognizing a … Read more

How to Convert UIImage to CIImage and vice versa

CIImage *ciImage = [UIImage imageNamed:@”test.png”].CIImage; UIImage *uiImage = [[UIImage alloc] initWithCIImage:ciImage]; To fix the case where myUIImage.CIImage returns nil like [UIImageView image], you can instead do [CIImage imageWithCGImage:myUIImage.CGImage] – Dylan Hand Swift version: let ciImage = UIImage(named: “test.png”)!.ciImage let uiImage = UIImage(ciImage: ciImage) To fix the case where myUIImage.ciImage returns nil like you can instead … Read more

Programmatically send to front/back elements created from interface builder

There are a number of methods of UIView that allow you to modify the view hierarchy. bringSubviewToFront: sendSubviewToBack: insertSubview:atIndex: insertSubview:aboveSubview: insertSubview:belowSubview: exchangeSubviewAtIndex:withSubviewAtIndex: Since your views are already inserted into your superview, you could easily call bringSubviewToFront: once for each view in whatever order you like.

How to zoom in/out an UIImage object when user pinches screen?

As others described, the easiest solution is to put your UIImageView into a UIScrollView. I did this in the Interface Builder .xib file. In viewDidLoad, set the following variables. Set your controller to be a UIScrollViewDelegate. – (void)viewDidLoad { [super viewDidLoad]; self.scrollView.minimumZoomScale = 0.5; self.scrollView.maximumZoomScale = 6.0; self.scrollView.contentSize = self.imageView.frame.size; self.scrollView.delegate = self; } You … Read more

Is it possible to prevent an NSURLRequest from caching data or remove cached data following a request?

Usually it’s easier to create the request like this NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0]; Then create the connection NSURLConnection *conn = [NSURLConnection connectionWithRequest:request delegate:self]; and implement the connection:willCacheResponse: method on the delegate. Just returning nil should do it. – (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse { return nil; }

Storing custom objects in an NSMutableArray in NSUserDefaults

For loading custom objects in an array, this is what I’ve used to grab the array: NSUserDefaults *currentDefaults = [NSUserDefaults standardUserDefaults]; NSData *dataRepresentingSavedArray = [currentDefaults objectForKey:@”savedArray”]; if (dataRepresentingSavedArray != nil) { NSArray *oldSavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:dataRepresentingSavedArray]; if (oldSavedArray != nil) objectArray = [[NSMutableArray alloc] initWithArray:oldSavedArray]; else objectArray = [[NSMutableArray alloc] init]; } You should check … Read more

What is the entry point of swift code execution?

The entry point in a plain Swift module is the file in the module called main.swift. main.swift is the only file which is allowed to have expressions and statements at the top level (all other Swift files in the module can only contain declarations). Cocoa Touch uses the @UIApplicationMain attribute on an implementation of UIApplicationDelegate … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)