Posts

Showing posts from October, 2014

Change Status Bar text color in iPhone

Image
Go to --> Info.plist :   1) View controller-based status bar appearance : NO   2) Status bar style : Opaque black style

Scroll UITextField above Keyboard in a UITableView OR UIScrollView in Swift and Objective C

In Objective C -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {     CGPoint pointInTable = [textField.superview convertPoint:textField.frame.origin toView:_tableview];     CGPoint contentOffset = _tableview.contentOffset;         contentOffset.y = (pointInTable.y - textField.inputAccessoryView.frame.size.height);         NSLog(@"contentOffset is: %@", NSStringFromCGPoint(contentOffset));        [_tableview setContentOffset:contentOffset animated:YES];        return YES; } -(BOOL)textFieldShouldEndEditing:(UITextField *)textField {     [textField resignFirstResponder];        if ([textField.superview.superview isKindOfClass:[UITableViewCell class]])     {         CGPoint buttonPosition = [textField convertPoint:CGPointZero                                                   toView: _tableview];         NSIndexPath *indexPath = [_tableview indexPathForRowAtPoint:buttonPosition];                 [_tableview scrollToRowAtIndexPath:indexPath atScrollPosition:UITableV

Check for an active Internet Connection on iPhone SDK

METHOD 1: Use a simple (ARC and GCD compatible) class to do it 1) Add SystemConfiguration framework to the project but don't worry about including it anywhere 2) Add Tony Million's version of Reachability.h and Reachability.m to the project (For Reachability download) 3) Update the interface section     #import "Reachability.h"     // Add this to the interface in the .m file of your view controller     @interface MyViewController ()     {         Reachability *internetReachableFoo;     }     @end 4) Then implement this method in the .m file of your view controller which you can call     // Checks if we have an internet connection or not     - (void)testInternetConnection     {           internetReachableFoo = [Reachability reachabilityWithHostname:@"www.google.com"];                 // Internet is reachable         internetReachableFoo.reachableBlock = ^(Reachability*reach)         {             // Update the UI on the main thr

Check if a string contains another string in iOS 8

NSString * string = @ "hello bla blah" ; if ([ string containsString :@ "bla" ]) { NSLog (@ "string contains bla!" ); } else { NSLog (@ "string does not contain bla" ); }

CGRectIntegral

Image
CGRectIntegral : Returns the smallest rectangle that results from converting the source rectangle values to integers. It's important that CGRect values all are rounded to the nearest whole point. Fractional values cause the frame to be drawn on a pixel boundary . Because pixels are atomic units (cannot be subdivided) a fractional value will cause the drawing to be averaged over the neighboring pixels, which looks blurry. CGRectIntegral will floor each origin value, and ceil each size value, which will ensure that your drawing code will crisply align on pixel boundaries. As a rule of thumb, if you are performing any operations that could result in fractional point values (e.g. division, CGRectGetMid[X|Y] , or CGRectDivide ), use CGRectIntegral to normalize rectangles to be set as a view frame.  Technically, since the coordinate system operates in terms of points, Retina screens, which have 4 pixels for every point, can draw ± 0.5f point values on odd pixel

Xcode 6: keyboard not showing up in ios simulator

Image
Go to--> iOS Simulator -> Hardware -> Keyboard Uncheck "Connect Hardware Keyboard"