Featured
-
Objective C or Swift - Which Technology to Learn for iOS Development?
Swift programming language is completely based on
by siddharth.sindhi -
Make UIImage White Background Transparent in iOS
If you came across to a requirement where you want
by ashish.nakoti -
User's location update on server when app is in background.
Code for those Apps where we need to update user's
by ashish.nakoti -
Animate button with zoom and bounce effect in ios
Many social apps are using bouncing effect for but
by ashish.nakoti -
Crop an image from UIImageView
With the following method stated below you can cro
by kuldeep.butola
Tags
IBDesignable
IBDESIGNABLE is available in Interface builder since Xcode 6.. We use IBDESIGNABLE to add additional properties to the view not only just the view but UILabel UIButtons and more..
By default properties are present related to views. In some case,...
Singleton class
A special type of class where only one instance per process is created and used is Singleton class. Singleton classes are commonly used the time when general services were offered by some classes. In Singleton class we can store values and wherev...
Applying constraints using code in ios
We can apply constraints with the help of coding also.
Suppose we have a button and we have to give constraints to it so below coding can help us to do so.
Lets make a custom button first.
UIButton *firstButton;
firstBut...
Storage Classes
Storage classes are used to check the visibility and scope of the variables. There are 5 types of storage classes.
auto storage class->
the auto storage class is a default storage class and it is for all local variables...
Table View
Table view is one of the most frequent iOS app UI element. In iOS many of the apps utilize tableview to exhibit a list of data. Special features of tableView include headers, footers, rows, and section. It provides a list of options fur...
How To transfer data from one viewcontroller to another viewcontroller in Tabbar?
If we have to transfer data from one view controller to another then we generally use prepare for segue method but in case of Tabbar do not need to use that method, we can directly send data in following way:
For Example: suppose we ...
Concept of protocols in Objective-C
Protocols are another important feature provided by Objective-C language. Basically protocols are used for a particular situation according to the need of a program. Within protocol methods will be declared which are expected to be used for a par...
iCloud
Apple iCloud
With the help of cloud computing technology Apple introduces iCloud storage for Apple devices. It's an online storage space given by apple so that you can save any data or access it. iCloud, is designed to work seamlessly with...
New Features in iPhone and iPad
Night Shift
iOS 9.3 has introduced night shift feature for iPhones, which automatically tints our screen to warmer colors(less blue light) at nighttime, so that we don’t have to change the setting by our own for nighttime(like ...
How to change size of UITEXTVIEW according to its text ?
To change the size of a UITextView to its contents i.e as the content of the UITextView increases the size of the textview will also increase.
We can implement this by applying the following code :-
- (void)textViewDidChange:(UITextView *)t...
Different functionality related to NavigationBar .
Here are listed some of the functionalities that can be implemented on navigationBar:-
The below code will Hide the back button from NavigationBar :-
self.navigationItem.hidesBackButton = YES;
Thie below code will Set background image ...
Collection View
Collection view is used to display multiple data simultaneously on view controller.Data can be of any type for example collection of text or images which can be display on controller with the help of collection view.
With the help of...
Show date picker along with done button when selecting UITextField
If we want that when we tap on a UITextField then date picker should show, so we can use following code-
[yourTextFieldOutlet setInputView:_datePicker];// _datePicker is the DatePicker type property
Here we want to add done button on a D...
How to Drag and Drop a View from one Position to Another
To add a Drag and Drop functionality in your Application You just have to append the below Code in your app.
//This function is called when the user touches any object
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)eve...
Left padding to the TextField
Whenever we use TextField then bydefault we don't get front space. Sometimes we want that our text should start after some gap so in that case we can use padding. In padding we can give space according to our need. There are two types of padd...
display data in two columns in collection view
We can display data in two columns in a collection view. In below code we are dividing the width of the cell into two parts of the collection view.
- (CGSize)collectionView:(UICollectionView *)collectionView
layo...
NSUserDefaults
NSUserDefaults is used to save the data until the app is installed. When data to NSUserDefaults is written by you then it will automatically gets loaded when your app runs so that you can read it back again.
In NSUserDefaults we use key to sav...
How to fetch meta data of an image in iOS
Metadata can be described as data about data here the metadata of an image we will fetch by using code in IOS9 . Metadata of an image includes resolution,gps location,creation date,modification date etc. here we will discuss a very simple way to ...
How to move UITextField when keyboard shows ?
When we are entering text in a textField and that textField is at bottom of the screen then we need that the textField should appear above the keyboard and the keyboard should not hide the textField.. For that we need to set the height of keyboar...
Stack View
Stack view is a good option to give less number of constraints to the storyboard items. If we are using stack view then we don’t need to give constraints to each label or button or any object, we can directly place labels or buttons or anyt...
Size Class and Auto Layout
Size Class is used when we need to have different constraints for different screen sizes or orientations.
The following table shows how the size classes apply to the different devices and orientations:
Verticle size C...
How to create marquee effect on imageview in Objc
To create marquee effect first set scroll view either via storyboard or via code
Here in this example I am setting up scroll view via code.
declare these variables
UIScrollView *scrollView;
NSTime...
How to add and access TextField in UIAlertController ?
The following code will show the Alert with textField :-
UIAlertController *alert=[UIAlertController alertControllerWithTitle:@"Alert Title" message:nil preferredStyle:UIAlertControllerStyleAlert];
// to add textField
[aler...
How to add Gradient effect to UIButton ?
Hello all !
For adding Gradient effect to the UIButton we can implement the following code :-
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = _customButton.layer.bounds; // _customButton is the outlet ...
How to give bottom border to your textField
By using below code you can give bottom border to your text fields
-(void)giveBottomBorderToTheTextField:(UITextField *)textField{
CALayer *border = [CALayer layer];
CGFloat borderWidth = 2;
border.borderColor = [UIColor...
Change background color of uibutton using subclass method
Hello all !
Explanation is,
Suppose we want to change the background color of the UIButton when it is selected and when reSelected change it to the default colour.
There are many methods for doing so and one of them I am explaining below :-
...
Change the PlaceHolder colour
As we know that we can't change the place holder color of the Text Fields but sometimes if we need to change it then we can do it by using following code.
UIColor *color = [UIColor grayColor];
self.myTextField.attributedPlaceholder = [[...
Share text on whats app in iOS
Opening whatsapp:// URL with one of the following parameters, will open whatapp and perform a custom action like sharing of text:-
1- Add whatsapp in LSApplicationQueriesSchemes to your info.plist
2- Message will be diplayed as M...
HOW TO MOVE FROM ONE CONTROLLER TO ANOTHER WITHOUT SEGUE?
Hello all !!
Explanation of the topic is :--
Whenever we have to move from one controller to another we usually do it by performing Segue between the two view controllers in the MainStoryboard..
The segue requires an identifier and from wher...
Tabbed Application in iOS
In this blog we are displaying that how we can create a tab bar based application in iOS.
Step 1. Create a new project and select Tabbed Application Template instead of the Single View Based application and click next.
Step 2. Name that app...
Autoplay the Youtube video in UIWebview in iOS
if you are using the UIWebview and want to autoplay the video from url then just add the "autoplay=1" at the end of the url.
Here is the code:
NSString *url=@"https://www.youtube.com/watch?v=vs3sVrm_W4o&autoplay=1";
[se...
How to add multiple images with animation in UIImageview in iOS
If you want to display the multiple images with animation in UIImageview then use the following code:
Here you can also set the repeat count of the images.
UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.boun...
How to convert from NSSTRING TO NSDATE ?
// date from string
NSString *dateString = [NSString stringWithFormat:@"%@",_model.time]; // model.time is the field in which we are fetching the string.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFo...
How to calculate distance from array of coordinates in iOS
If we want to calculate the distance from the array which contains the coordinates i.e Latitude and Longitude then use the following code-
-(void) getDistanceFromArray {
CLLocationDistance totalKilometers = 0;
for (int i = 0; i < ...
How to use the Autocomplete API with Google Maps SDK on iOS
By Using the following code you can integrate the Google Maps SDK in your iOS project.
First we will write the function which results the array of related nearby places.
-(void) searchLocation:(NSString *)locationName{
GMSAutocomplet...
How to add new .pch file to your Xcode Project?
From Xcode6 and later .pch file is not created automatically. One has to create it manually.
Following are the steps to add/create a pch file in your xcode project:
Create a new file using: cmd+N
• &nbs...
Pass data from one ViewController to another in iOS
I’ve just created second view controller class by extending from the UIViewController class. However, it doesn’t differ from the parent class until we add our own variables and methods. There are a couple of things we have to change:
...
How to remove any section of webpage before load it in UIWebView
If we want to remove any section from webpage like header or footer than use the following code.
In the following code header and footer.footer are the tag identifier of html Class.
We have to use the appropriate tag of the control which we...
How to get Image Filters in Core Image framework
Hi Readers!
Many times we need to check what Core Image filters do we have in iOS framework. Here is a simple code to get all the list of filters with their attributes. This will be easier for you to check and apply any filter on an image.&nbs...
How to create UINavigationController Based Application in iOS
The UINavigationBar class provides a control for navigating hierarchical content. It’s a bar, typically displayed at the top of the screen, containing buttons for navigating within a hierarchy of screens. The primary properties are a left (...
How to launch Apple Maps from iOS app
Hi Readers!
Below is the code to launch the Apple Maps application and display the directions between 2 points on Map.
Example 1: Display directions
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2...
Sorting an Array ios
Hello Readers,
To sort an array in ios you may use the following code snippet:
// Name of the key on basis of which you want to sort
NSSortDescriptor *dateDescriptor = [NSSortDescriptor
sor...
Different AppStates in iOS
THESE ARE THE APPSTATES IN IOS
AppState tell that whether the app is running in foreground or background or when the state changes..
In early versions of iOS three states were supported : n...
Get the list of All Available Font in ios
To get the list of all the font that is available in xCode you can use this code.
for (NSString *name in fontnamesArray) {
NSLog(@"Font Family: %@",name);
NSArray *fontFaces = [UIFont fontNamesForFamilyName:name];
...
History of Objective-C
History of Objective C
Brad Cox and Tom Love are those famous personalities who invented Objective C in 1980 for their company Step stone. They introduced Smalltalk at ITT corporation's programming technology centre in 1981.
Brad ...
UIAlertController in iOS
For iOS 8 and above Apple have introduced UIAlertController to present action Sheet and alerts.
In order to present alert set preferredStyle to UIAlertControllerStyleAlert and for actionSheet preferredStyle to UIAlertControllerStyleActionShee...
Auto Layout Using Visual Format Language In Swift
Hi All,
You can add auto layout constraints by using Storyboard Interface OR by adding constraints dynamically. There are three ways to add constraint dynamically (as per Apple Inc.)
Visual Format Language is one of the way is used to a...
Auto Layout Using NSLayoutConstraint In Swift
Hi All,
You can add auto layout constraints by using Storyboard Interface OR by adding constraints dynamically. There are three ways to add constraint dynamically (as per Apple Inc.)
NSLayoutConstraint is one of the way is used to add autol...
Adding auto layout constraint dynamically in swift
Hi All,
You can add auto layout constraints by using Storyboard Interface OR by adding constraints dynamically. There are three ways to add constraint dynamically (as per Apple Inc.)
Layout Anchor is one of the way is used to add autolayout...