Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

How to use UIAlertController for iOS8 and above.

Apple has deprecated UIAlertView in iOS 8 and above. Now they have introduce UIAlertController, below are the examples. AlertView without buttons:- UIAlertController * alert= [UIAlertController alertContro...

How to check Push Notification enabled in iOS

For your iOS application if you want to check Push Notification status then you can check it by using the below code:- in iOS 7 UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if (types ...

Add a thin line to UITextField in iOS

For textfield we use attributes to give outlines to it or some times we place image view behind every textfield for its outline. We can instead use CALayer for it. I am setting an upper outline to a textfield, here is the code:- CALayer *upper...

How to create a custom UITableViewCell separator in iOS

In UITableView every UITableViewCell contains a separator line by default. If you need to create your own custom separator line then use below code inside cellForRowAtIndexPath method. UIView* separatorLineView = [[UIView alloc] initWithFrame:...

How to create a custom back button in iOS

Some times we need to create a custom back button for Navigation Bar in iOS. If you want to create an easy navigational back button instead of creating a view and add that view in navigation bar then use below code to achieve it. UIButton *bac...

How to check BOOL value of Parse Object in iOS

If you are a beginner in Parse SDK and integrating it for the first time then you may face this little hurdle. While fetching Boolean data from Parse DB we get BOOL value in NSNumber format and we can not check or compare it directly with iOS bo...

Custom message for Location permission alert in iOS

If you are using Location Manager to get user's current location then you have ask Location Permission first. iOS provides you access to user's location if user accepts it. Here is the code :- Below code will return you location manager object...

Play a video from a URL in iPhone SDK

To play a video from a url in iPhone sdk just write down following line of code: Step 1: Create a MPMoviePlayerViewController object as *moviePlayerController. Step 2: Create a Url and initialize your movieController with Url. Step 3: and No...

Round or Circular ImageView in iOS

You may have seen several mobile applications with round or circular image view. It is mostly used while displaying User's profile pic or in a tabular representation of images. You can do it very easily without using third party classes or Librar...

Check a string with special characters in ios

If you want to check any NSString containing special characters then check this out. -(BOOL)specialCharacter:(NSString*)username{ NSCharacterSet *invalidCharSet = [[NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTU...

Email Validation in iOS

While creating any Login or Registration UI in iOS we ask user to enter their email id. To avoid wrong data entry we can validate entered data by using a simple validation method. Below method will return you a BOOL value. Here it is:- -(BOOL...

How to use predicate in ios

In iOS we can use Predicates in order to get fast response. Mostly iOS developers use Predicates in search functionality to filter it as user types in search bar textfield. Let suppose you have an array named as youDataArray which contains s...

How to take a screenshot of an iPhone screen in iOS

Some times we don't get a correct screenshot of an iOS device. Specially when we apply some transform or animation. If you are applying affine transform or 3dTransform to an object and hoping for a perfect screenshot with same transform value the...

How to save image in to gallery in iOS

If you want to save any UIImage to iPhone or iPad gallery, just use below code to achieve it. These lines of code will write image file to your gallery. You just have to pass UIImage as param to it. UIImageWriteToSavedPhotosAlbum(yourUIImage,...

Reset any transform in iOS

In iOS when we apply transform methods to any UIView element like UIIMageView, UIView and all those UI Elements which inherits UIView properties. After applying transform to these views they get change and holds new transform values. In that case...

How to get device token in iOS

For iOS push notification services functionality we need a device token (a unique device id generated by device OS for Push Messages communications) on which we can receive push notification messages. To generate the device token we have to add U...

How to get iOS device type and version

If you need login device type, model and version of an iOS device, then use below code. You'll have to import below file first then:- // #import `<`sys/utsname.h> NSString* deviceName() { struct utsname systemInfo; uname...

Facebook Login in Parse

Parse provides simple Facebook login where it saves Access Token and limited user info. Inside your viewcontroller where you have implemented PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate delegates just call Facebook request as m...

Simple way to change status bar

If you need to change the color or appearance of the Status Bar of iOS then follow simple steps. in your code file where you had created or initialized UINavigationController just write few line of code there. Find similar line as mentioned...

How to Change the Font and Color of UITextField's Placeholder

Hi Readers, Below are two simple lines you need to add to your code for changing the font and color of the UITextField's Placeholder. _txttest.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:30.0f]; _txttest.attribut...

How to add a Podfile in your Project

Below is the step-wise process for integrating a Podfile easily in your Application. Open Terminal Change the directory in Terminal to the location where your Xcode project resides. When you reach to the desired project location in which ...

How to upload image in Specific folder of your application iOS

Here is the code for UIImagePickerController Delegate. In this Code when we select an image from UIImagePickerController then we call this delegate function which upload the selected image to your local application folder. You have to first find ...

Download Files Using DropBoxSDK in iOS

If You want to get the list of all the files that are uploaded on your DropBox then use the following code : method -(void)downloadAllData:(void (^)(NSMutableArray *, NSMutableArray *, BOOL)) block need to be called after the successful lo...

Invalid attempt to access ALAssetPrivate past the lifetime of its owning ALAssetsLibrary

When accessing assets in the iPhone, some time users gets this error. (Invalid attempt to access ALAssetPrivate past the lifetime of its owning ALAssetsLibrary) so we can initialize our assetLibaray using the following code: + (ALAssets...

DropBox Login Integration Using iOS SDK

Download the DropBox SDK from the https://www.dropbox.com/developers/sync/sdks/ios add this sdk to Your project and also add some other Frameworks. 1. Foundation.framework 2. UIKit.framework 3. CoreGraphics.framework 4. QuartzCore.fra...

Fetch profile pic from Facebook

For some reasons Facebook doesnt provide profile picture with user info dictionary/data. We need to fetch profile pic using graph api. Once user is done with successful authentication he can use following snippet to get profile picture URL. ...

Send mail using iOS

Sometimes we need to send the email from iOS application for that we have to integrate MFMailComposeViewController in our application so that we can send email. This program will help you to send email through your app using swift. Steps Requ...

How to iterate or remove all key object from NSUserDefaults

Hi Readers, In any iPhone app if it is needed to iterate or remove NSUserDefault keys (as in logout feature), following code can be used: To iterate key objects: NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; ...

Fetch the Contact Detail Using iPhone SDK

In iPhone application development it is required to fetch the contact detail that are saved in the contact list of iPhone. So here is the program that will help you to fetch the detail of the contact with name number and contact image, if the i...

How to give background color to superview only with alpha less than 1.0

Hi, In many cases we have to give a background color to a superview with alpha less than 1.0. If we give color from XIB/storyboard to a superview with alpha 0.4 then it assigns the alpha 0.4 to its subviews also. What if we need to give al...

Autoplay media files in UIWebView in IOS

When displaying media content using HTML5 in a web view on IOS the autoplay functionality does not work. To enable to web view to autoplay the media (if coded in HTML to autoplay) you need to add a line of code in your IOS application as expla...

Save the other Object in array using for loop

To add the object in array in for Loop we have several methods: first we can have to simply add those objects to the array then we can add them using for loop in array..... **IN example:** we have a simple object *object that we added 3 tim...

How to get sub strings from a string using Regular Expression

Hi, The below code is to get substrings from a string. You are going to love this below code which is very simple but very effective. I have used regular expression to get the sub strings. NSString *strTest = @"Hii how are you doing @Ravi , h...

Interface and Property

Interface Interface is where you define the attributes and methods of class. In objective C the file where the declaration of class is done is called the interface file and the file where the class is defined is called the implementation file...

Mutable and Immutable Objects

Object which we create can either be mutable or immutable. For example: Immutable : NSString *str = [[NSString alloc]init]; Mutable: NSMutableString *str = [[NSMutableString alloc]init]; When we edit Mutable Object it will chang...

Rounded corner in XIB or storyboard

Hi, I am writing for the first time on FindNerd. Many times we need to make buttons, labels, imageview, view to have rounded corner. and we write code as below to perform it. [redButton.layer setCornerRadius:15.0f]; [redButton.laye...

Divide image in equal parts wrt number of row and number of column.

With the help of following code you can divide UIImage into equal parts w.r.t number of row and number of column. Create a category of UIImageView and UImage and write the following method respectively in them. -(NSArray *)divideImageViewIn...

resize UIImage without losing quality (not screenshot)

Use the below code for cutting UIImage in high quality without blur (not screenshot) tmp is image view <p>UIGraphicsBeginImageContextWithOptions(tmp.frame.size,YES, 4.0);</p> <p>CGContextRef c = UIGraphicsGetCurrentCon...

Crop an image from UIImageView

With the following method stated below you can crop an UIImageView. -(UIImage *)cropedImage:(UIView *)view{ UIGraphicsBeginImageContextWithOptions(view.frame.size, imageView.opaque, 4.0); CGContextRef c = UIGraphicsGetCurrentConte...

Compile your code even when application is in background

When application enters in background the compiler stop working and it has to wait till application enter foreground. Use following code to compile some of your code even when application is in background bgTask = [application beginBackground...

How to create a custom Spinner

To create a custom spinner create a custom view with the following initialization method - (id)initWithFrame:(CGRect)frame superViewFrame:(CGRect)superViewFrame { self = [super initWithFrame:frame]; if (self) { // Initializ...

Convert HTML string to Plane NSString

Hi Friends, Sometime in API responses we get html strings. To get pure string from html string this code will help you. NSString *htmlStr = @"html String"; NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; NSDict...

How to detect screenshot taken by user in iPhone.

With the help of the notification "UIApplicationUserDidTakeScreenshotNotification" in our application we can detect the screenshot taken from iPhone. Use the following line of code to generate notification for same. [[NSNotificationCenter def...

URL encoding in ios

Hello all, I was facing problem with loading URL in UIWebVIew because of wrong encoding method. After that I tried this code. It helped me. - (NSString*)encodeURL:(NSString *)string { NSString *newString = NSMakeCollectable([(NSString *...

Customize commit editing style delete button in UITableViewCell

Hello All, Following lines of code will customize the delete button in UITableView editing style. This is an override method of UITableViewCell which is called when UITableView goes in editing mode. So to customize the delete button in UITable...

How to pass the method name as argument string

Sometime we don't know name of the method at compile time. So pass the method name as argument and use the following lines of code. NSString *methodname=@"calltest"; SEL aSelector = NSSelectorFromString(methodname); NSInvocation *inv = [NS...

Open CSV and PDF file in your application

Add following line of code in your Plist file to open CSV and PDF file in your application. Please note that UTTypeIdentifier should be unique. <key>CFBundleDocumentTypes</key> <array> <dict> ...

Custom right bar button in UINavigationBar

Hello friends,This code is to make custom right bar button in UINavigation bar. it helped me to make custom right bar button in UINavigation bar, Hope this will help you too. UIButton *homeButton = [UIButton buttonWithType:UIButtonTypeCustom...

Detect device orientation and set UI according to orientation dynamically.

Hello Friends, these lines of code will help you to detect device orientation and set UI dynamically according to orientation. - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { NSLog(@"rotate");...

Load url in UIWebView.

Hello All, Following lines of code will help you to load url in UIWebView and make it fit to IPhone screen. In .h file IBOutlet UIWebView *webView; In .m file [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@...
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: