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 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...
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 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 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...
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...
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...
How to give border color to UIButton in objc and Swift.
To give border color to UIButton :-
1. Take UIButton as property .
2. Give corner radius and corner width to UIButton.
3. Now give border color to UIButton.
For Swift use :-
demoButton.backgroundColor = UIColor.clearColor()
demo...
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];
...
Zoom mapview to show all annotaions
Hi all,
If you are adding multiple annotation in your amp and you want to show all annotations initially. then just call this method after adding all annotation to your mapview.
There are some globally declare variable such as :-
#defin...
How to play a video file ios
Hello Friends,
Create an object of MPMoviePlayerController:
MPMoviePlayerViewController *moviePlayerController;
NSURL *videoUrl=[NSURL URLWithString:@"String value of your url"];
Initialize the instance of MPmoviePlayerViewControl...
Calculate distance between two point and draw route on map
Hi all,
Let take you have two points, Point1 (In Boston) and Point2 (In Atlanta), Now you have to show the route between two points.
In below method , you have to pass two param's i.e.. two point of map.
- (void)displayRouteFrom:(CLLoca...
Change color of polyline
Hi all,
If you want to change the color of a polyline or route on map just change the color in this delegate of map.
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay
{
MKPolylineRen...
Adding card with braintree
Hi All ,
These are simple steps to add card to braintree account in iOS.
1.Initialize braintree object with valid client token.
BTAPIClient *token = [[BTAPIClient alloc] initWithAuthorization:@"cleintToken received from tree"];
...
Slide menu application in iOS.
Hi Friends,
I know there are several applications which are using Slide Menu option. You can find several libraries or classes in Objc to build an app like that.
Here is the most easy and customizable class to get it. Its name is SKSlideVie...
Change UISearchBar Field Text Color in iOS
You can change UISearchField text color in iOS. Use single line of code to do it.
[[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
Happy Coding!!!
Change UISearchBar appearance in Objective C
If you want to change the appearance of UISearchBar and its related elements then use below code.
-(void)changeSearchBarAppearance{
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setBackgroundColor:[UIColor whiteCol...
How to create first iOS application in Xcode?
How to create first iOS application in Xcode for iPhone with no programming experience where Ill help even the non-programmer to enjoy coding as an iOS developer.
This is an XCode tutorial for beginners so Ill be going through where to downlo...
Seat Selector For iOS
Hi All,
Now days , we start booking seats online so if you also want to implement seat selection functionality than follow these steps .
Download ZSeatSelector from this link https://github.com/richzertuche/ZSeatSelector
Now drag two fil...
Get contact name and phone number
Hi all,
If you want to get contact name and contact number from your iphone contact list then below two methods can help you to get contact name and contact phone number .
Note: In this you will only get those contacts,which contain phone ...
Save and retreive text from text file
Hi all,
If you want to save anything in text file or any kind of file than you can follow this code. This code will save text to textfile in your application directory.You can retrieve text from save file later on .
NSError *error;
NSStrin...
Chaneg Textview height according to text
Hi All,
If you want to change height of textView according to content height than you can follow this code.
Use auto layout to set view in story board and make IBOutlet for textview . Assign delegate to textview and dont give height constra...
Show flags using Unicode
Hi All,
If you want to show flags in using unicode hex coding (U+XXXX) than you can follow this code .
UNICODE:- Unicode is a computing industry standard for the consistent encoding, representation, and handling of text expressed in most of...
Convert NSString to NSDate and vice versa
HI all,
If you want to convert NSString to NSDate ,then you must use NSDateFormatter to convert please follow this code .
NSString to NSDate
In Objective-C :-
NSString *dateString = @"11-11-2015";
NSDateFormatter *dateFormatter = [[...
Delete object from Parse table in iOS.
If you want to delete an object from Parse DB then you have to run a query to fetch that object and then run a loop to delete it. If you already have that object then just call delete method. Here is the complete code.
PFQuery *query = [PFQuer...
Post/Blog Sharing time formats like Facebook, Twitter in iOS.
There are several posting time formats available, social sites are using their own styles of post time display. But the logic behind each posting is same, basically it depnds upon the date and time difference. Here is the function to calculate th...
Get thumbnail image from a recorded video in iOS
If you want to get thumbnail image from the recorded video in iOS then you can cut a small frame from that video to generate an image. You just need to send video output URL to below method as a parameter. This method willl return you NSData. Lat...
Property List of MPMoviePlayerController for iOS
There are several properties available for MPMoviePlayerController in iOS. We just need to use them to play the movie according to our need.
You can access these properties like this:-
Create property in .h file
@property (strong, n...
how to merge objc and Swift code in same project
To use swift code in Objective-c project ->
1. Go to your objective-c project -> create a new file -> source -> Cocoa Touch Class -> change language to Swift -> create.
2. Now a alert will pop-up Would you like to configur...
Fetch Parse PFUser data in iOS
If you are querying on Parse User class and not getting the user data of custom columns then use below code.
PFQuery *query= [PFUser query];
[query whereKey:@"username" equalTo:[[PFUser currentUser]username]];
[query getFirstObjectIn...
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...
Hide Status bar in iOS
In iOS apps when we need to hide control center appears in iPhone device on swipe up gesture or forced to hide UIStatusBar then use below code.
Write below lines in your viewDidLoad method.
if ([self respondsToSelector:@selector(setNeedsSta...
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...
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...
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...
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...
Set date of a Date Picker in Objective C
In objective C, UIDatePicker is the best way to display date and time options. We can set date of our choice in a Date picker. Also we can set minimum and maximum date.
Here I am creating UIDatePicker first.
UIDatePicker *pickerDate...
Reverse an array in Objective C
If you want to reverse an existing array in objc, you can do it this way.
- (NSMutableArray*)reverseArray {
if ([self.assetsArray count] == 0)
return;
NSUInteger i = 0;
NSUInteger j = [self.assetsArray count] - 1;
...
Redirect to app settings in iPhone
If you want to redirect to app settings from your app then use below code to do it. Apple provides a list of URLs to redirect the app to its setting section. Here is the code :-
In a Swift Program:-
UIApplication.sharedApplication().ope...
Zoom in an UIImageView using 3D transform in objc
If you are looking for a function to Zoom in an UIImageView in a 3D tranform scale then you should use CATransform3DScale.
First of all declare a BOOL variable to check scale points. Here I am taking CGFloat _scalePoints and CATransform3D tr...
UIButton width according to Title text.
We can increase or set width of a UIButton according to button title test. To set the width of a UIButton use CGSize. Here is the code :-
CGSize stringsize = [yourButton.titleLabel.text sizeWithFont:[UIFont systemFontOfSize:17]];
[yourButto...
Add Input Accessory View above UIKeyBoard in iOS
If you come across a requirement where you want to add a custom view just above the UIKeyBoard, then you can use below code to do that.
If you want to show custom view on tapping inside any UITextField or UITextView, Write below line of code i...