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
How to show delete button on UITableView on swipe left ?
One of the commonly used feature in UITableView is to show delete button on the swipe of the table view cell and perform the delete operation. Let us take an example to understand and implement this :-
Begin by creating a new project and assig...
Core Graphics Concept
Hi readers!
This blog includes an example of core graphics with multiple choice option available to the user to draw different shapes in an application. Different shapes which we are going to draw in this application are line, sphere...
How to send a request with parameters in Alamofire
Alamofire is HTTP networking library for iOS and Mac OS X, which is written in swift. Alamofire is based on NSURLSession,but it make network code much easy to write.
Following function is available in Alamofire.
.upload
.down...
HealthKit Introduction
Hi Readers
This Tutorial is a brief introduction about the new feature introduced in iOS 8 ,that is, HealthKit.It gives us the way to store and retrieve a user’s health data.
Before using this HealthKit let us go through the app via w...
How to use the built-in camera of the iPhone ?
To use the built-in camera of the iPhone consider the following example. In this example we will also see how to access the photo library and select a photo and use it.
Create a single view application and assign a name to it. Then in the Main...
UICollectionViewCell with dynamic cell height
Sometimes we require dynamic height of UICollectionViewcell according to text of our label like this:
To get output like this do following steps.
Go to your storyboard, from "object library" drag a co...
Collection View
Collection view is used to show data in a grid form. It is similar to table view where we have to implement its data source and delegate methods.
In this example, we will implement collection view.
Drag a UICollectionView to the d...
How to scan barcode?
This blog includes the concept of scanning the bar codes but before proceeding towards the topics we will discuss bar code. A barcode can be defined as an optical machine-readable representation of data relating to the object to which it is attac...
How to create a UIPopoverView programmatically in iOS 9
To create a popover view
Go to your storyboard, set a button in view controller(on click of this button we will pop a popover view).
Make an IBAction form this button to your view controller
eg:- (IBAction)popoverBu...
Line Break on UIButton Text
It is possible to set number of lines of a label by going to the Attribute Inspector and assigning value 0 to the lines attribute.
In case of Text Field we can use Text View but if we are using UIButton then there is no option for the mu...
Adding bounce effect to UIImageView .
We can add animation to view using CABasicAnimation. Here we are adding bounce effect to UIImageView.
The following code will show the bounce effect in the UIImageView at y-axis:-
CGPoint origin = self.imgView.center; // self.imgView i...
How to create your own search bar in Swift (Not using UISearchBar)
Here is a small example of custom search bar
1. Go to storyboard, take TextField place it at below navigation bar (we will type text here to find any string)
2. Set delegate of TextField
Come to ViewController class now
Create I...
How to use Core Data in iOS Part 2?
Hi Readers!
This blog includes the advance topic of Core Data which is relationship between two entities. If you are not familiar with the concept of Core Data you can view the link to understand the Core Data (Part 1). Link include th...
Use Drop Down Error Notification instead of pop-ups in iOS
Popups are amazing way to notify/alert user, popups provide us necessary additional info about the app and can be used for assisting user when anything went wrong. After using traditional popups now it’s time for Dropdown popups.
Clic...
How to use UIStackView in iOS 9.0
Stack View is a class that allows you to layout views either a vertical or horizontal manner. It saves us from use of constraints in auto layout. We simply embed our views to StackView to make it work. Stack View manages the layout of its su...
How to make some part of string bold in UITextView or UILabel?
If you want to set some part of the UITextview to BOLD then you can implement the following code :-
NSString *str = @"I belong to Dehradun"; // default string
NSMutableAttributedString *attString=[[NSMutableAttributedStrin...
How to use NSAttributedString in UITextView?
We can use attributed string with textView by following steps -
1. Make a IBOutlet of your textView
for eg -
@property (weak, nonatomic) IBOutlet UITextView *textView;
2. Now go to storyboard and select your textVi...
How to use Core Data in iOS Part 1?
Core Data framework is used to store data in the form of entities and maintained by Apple in a very well defined manner. Here is an example usage of Core Data to insert,delete,update and fetch data from entities with in the same. To use Core Data...
Delegates in iOS
Means of communication between the objects can be implemented using Delegates. One object can send messages to another object through delegates.
For example, if we want to pass data forward then it is easy through UINavigationController as...
How to set UICollectionView right align?
Hi Readers,
This blog will display the collection view content in Right To Left language such as Hebrew/ Arabic. Generally, you will see the collection view as displayed in the below screenshot.
To set UICollectionView right align first...
How to extract audio from Video using iOS sdk
This is how we can extract the audio from Video :
First import the video from libaray using imagePickerController delegates methods.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:...
Side MenuBar in iOS
Side MenuBar or menu list is used to provide a list to the user so that user can easily move to those pages according to the need. Here is an example of including menubar in the application with the help of a superclass REFrostedViewCot...
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...
How to add ChildViewController using container view in objc
We can add a ChildViewController using container by following code.
-(void)addChildViewController{
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
NSString *strClass = NSStringFromClass([YourChildViewContro...
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...
How to convert NSDate from local timezone to UTC and vice versa in objc
1. To convert UTC to local time zone
- (NSString *)convertLocalDateFromUTCDate:(NSString *)dateStr{
NSDateFormatter *formatter = [self dateFormatter];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"];
NSDate *sourceDate...
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...
How to add placeholder inside UITextView
To add placeholder UITextView first take outlet of UITextField
ex- @property (weak, nonatomic) IBOutlet UITextView *yourTextView;
Then follow these steps
1. In viewDidLoad add these line of code
self.yourTextView.text = @Please type he...