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 save and get image from parse database in iOS app
To save image or video into parse database, parse has provided a class PFFile. It can also be used to save documents, music files or any binary data file (upto 10 megabytes only).
To save image first convert image to NSData, assign it to PFFil...
Change Status Bar Color
Hi All,
To change statusBar color in any view controller, you need to follow three steps:-
First - Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file.
Second - In viewDidLoad function of your UIViewController
...
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...
Check for Internet Connection
Hi All
To check internet connection using objective c you can use this function.
There may be a plethora of reasons that you need to check whether or not the device that is using your application has an internet connection. If checking whet...
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...
Data pass between two viewcontrollers
Hi All,
If you need to pass data from one ViewContrlloer to other ViewController then first make properties in second ViewController in which you need that data For example:-
In SecondViewController.h
@interface SecondViewController : ...
How to disable user interaction of an iOS app
In iOS application there are only few ways to disable user interaction for the whole screen or UI. Some developers use property (User Interaction Enabled) for a specific control, some uses MBProgressHud class by displaying spinner or some uses us...
Create a PIe Chart in iOS
The main use of a pie chart is to show comparison. When items are presented on a pie chart, you can easily see which item is the most popular and which is the least popular.
you can create the pie chart in iOS by using the following methods...
How to use NSMutableAttributedString
Hello Friends,
NSMutableAttributedString allows to set different attributes(font size,font color) for different parts of the string.
To use NSMutableString you may use the following code:
//Create an object of NSMutableAttrinbuteString and ass...
Make a Call using swift
Hi All,
To call any number with code using swift you can use this function.
private func dialNumber(phoneNumber:String) {
let phoneUrl:NSURL = NSURL(string: "tel://\(phoneNumber)")!
let application:UIApplication = UIAppli...
How to implement local notification in iOS SDK
Hi Readers,
In iOS development of today scenario we may pass the data in different part of code either to selected class or broadcast. One way of broadcasting objects is local notification. Following is the way to implement it:
To broadcast...
How to make Rounded Image avatar in iphone,along with circular coloured border?
How to make Rounded Image avatar in iphone,along with circular coloured border.
Create IBOutlet of the image from the storyboard to your View controller as-
__weak IBOutlet UIImageView *imagename;
Now in your viewDidLoad ins...
Convert UIImage to NSData or NSData to UIImage
Hi all ,
To convert UIImage to NSData
Objective C
NSData *data = UIImagePNGRepresentation(self.MyImageView.image);
Swift
let imageData: NSData = UIImagePNGRepresentation(self.MyImageView.image)
To convert NSData to UIImage
...
Get data from two tables from parse database in iOS app
If two tables are connected through pointers, we can get data from both the tables using "include" key.
For example- There are two tables "Task" and "Task_Detail" and a pointer of Task_Detail is added as a column in table Task with name "detai...
how to create islamic calendar (hijri calendar) using iOS sdks
Following code will return the today's date in islamic calendar
NSCalendar *hijriCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSIslamicCivilCalendar];
NSDateComponents *hijriComponents = [hijriCalendar components:NSDayCal...
Read/fetch data from Parse database in iOS app
It is very easy to read data from Parse database, just create a query using PFQuery class over class name (table name) and request for data.
For example - There is one table "Post" with column names : title, message, postTime. Now get data fro...
Save data to Parse DB table in iOS app
To save data in parse DB table, create one PFObject and write the information that you want to save to table.
For example - I have a table name "Post" with column names : title, message, postTime. Lets save one record to this table.
PFObject ...
date picker in place of keyboard in UITextField
The date picker is used to pick date for textfield. It is placed in textFieldDidBeginEditing (a delegate method of UITextField), so that the keyboard is replaced with date picker as soon as you enter into textfield. updateTextField will set the ...
End Editing From Textfield ,Textview by just clicking outside textfield or textview
Hi All,
If you want to hide keyboard by touching outside of UITextfield or UITextViiew, just copy this function in your viewcontroller.
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self.view endEdi...
To call and send parameters to java Script function from Objective C
To call javascript function write the following lines :
NSString *getStringvalue=[webView stringByEvaluatingJavaScriptFromString:@"getName()];
Where getName() is a JavaScript function which return a String value.
and to send Objective C...
Load custom cell(Xib) in UITableView in swift
hello friends,
if you would like to Load custom cell(Xib) in UITableView in swift ,you may use the following code ->
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count; //...
test if an NSString is empty in Objective C
You can check if( [empName length]==0 || [[empName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) this will return 1 else 0
NSString *empName;
if ([empName length]==0 || [[empName stringByTrimmingCharac...
NSAppTransportSecurity to run API in iOS 9
Hello all ,
To run any API in ios 9 ,a key should be added in info.plist in supporting files folder in any project.
First select info.plist and open as source code and add this code starting of ...
<key>NSAppTransportSecurity</...
UnderLined TextField/UIView (to prevent unnecessary constraints..)
In your xcode project first create a UItextfield type of cocoa touch class in case of underlined view create a uiview type of class as UnderlinedTextField or watever name suits you.
In UnderlinedTextField.h file of your class create a property...
Check for the iPhone Models
To know On which hardware iOS is ruining like iPhone4 , iPhone5 etc below is the code for that
#import <sys/utsname.h>
-(NSString*) deviceName
{
struct utsname systemInfo;
uname(&systemInfo);
r...
Audio Playing while App is in Background Mode
In order to continue your audio running while the app is in Background mode(like in the case of live Streaming), we just have to add this line in our AppDelegate method application didFinishLaunchingWithOptions:
[[AVAudioSession sharedInstanc...
TableView in Swift
To create a tableView in swift please follow following steps:
Step 1: Add a tableView in viewController.
Step 2: set the dataSource and delegate
Step 3: Create a prototype cell
Step 4: Change the class of prototypecell to "TableView...
How to implement the Auto Layout Contraint through Code
Hi Readers,
This Post is just a brief introduction about How we can implement Autolayout Contraints through coding.
Now,Before moving ahead with the topic let us have a brief about AutoLayout.
WHAT IS AUTOLAYOUT...??
Auto Layout is a ...
How to use UIActivityViewController for sharing on iphone and ipad
Hello Readers,
In order to share text or links from the application, you may use UIActivityViewController . This is an easy way to share from within the application.
NSString *textToShare = @"text you would like to share"
NSURL ...
NSTimer in IPhone SDK
Here is the code for:
calling a method after a time interval delay.
we use the NSTimer to implement this.
NSTimer *timer= [NSTimer scheduledTimerWithTimeInterval:3.0
target:self
...
Alert prompt on screen
Hi,
whenever you need an Alert prompt, you simply need to create an object of UIAlertView and show the object wherever alert prompt is needed.
For example -
UIAlertView *alertView= [[UIAlertView alloc] initWithTitle:@"CAUTION" message:@"m...
Inter letter spacing OR different color to words of text of UIButton , UILetter , UITextfield
Hi all,
if you want to give inter letter spacing to any kind of text of button , label , textfields etc then you can follow this code.
First make attributed string :-
NSMutableAttributedString * title = [[NSMutableAttributedString alloc]...
Underline and Border of UIButton
Hi all,
To underline your button use this class :-
.h
@interface UnderLineButton : UIButton
@end
.m
@implementation UnderLineButton
- (void)drawRect:(CGRect)rect {
// Drawing code
CALayer *bottomBorder = [CALayer ...
Mb Progress Hud/Progress bar in iphone
1. Install pod " pod 'MBProgressHUD', '~> 0.9.1' " in your Xcode project
2. Once pods are installed successfully close your Xcode project & now open Xcode xcworkspace.
3. Now import mbprogress hud as #import "MBProgressHUD.h" in yo...
Find the country of the user
To find out the country of the user please use the code below:
1- Add the coreLocation Framework to your project and import #import <corelocation corelocation.h="">
2- Set the CLLocationManagerDelegate as UIViewController
@interface...
Setting up a GCM Client App on iOS
Google cloud messaging services is now available for ios developer,
Previously
For push in IPhone We have to use APN.
and
For push in Android we have to use GCM.
I think it is very difficult to implement both APN and GCM at SERVER level...
How to add/call plugin method from javascript
Use the following code to make plugin javascript
Here connectwebsocketserver is the function which called by javascript (index.js). If your plugin javascript file name is test then by following lin you can call this function
test.connectw...
How to create Cordova plugin directory structure
Hi,
Here is the steps to create cordova plugin directory structure : Install Yeoman by this command
$ npm install -g generator-cordova-plugin
then go to folder where you want that directory structure and run this command
$ yo cordo...
How to declare an Array in Swift
Hi Readers!
There are different ways to declare Array in Swift. I will write few examples below:
Example 1:
let a : Array? = ["hello","hi"]
Now in above example this is a constant array. You cannot add/append an element in it.
E...
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...
Why to use tuples if we have Arrays in swift language and How it is different from Structures?
Hi Readers,
Before Moving ahead with the Topic,Lets us Briefly have a overlook what actually a Tuple is:
* In very simple language:
A tuple is a group of zero or more values represented as one value.
For example ("Pen", "50") ...
What is an Optional meant in Swift?
Hi Readers!
An Optional is just an enum in Swift.
enum Optional<T> {
case None
case Some(T)
}
Here <T> is generic similar to an Array<T>
<T> could be anything like Strings, Dictionary, Array etc.
...
Error in __weak typeof(self)weakSelf = self
If you have error in line
__weak typeof(self)weakSelf = self;
replace this line with
__typeof__(self) __weak weakSelf = self;
Check Wifi Network reachability in Swift
In Swift if you want to check the Wifi connection in your device then use following code.
This is a function which returns Reachability instance (reachability class object) value as a returnvalue for wifi connection availability.
+ (instan...
Search a location in ios SDK
if you want to search a particular location using the google api so you can use this .
Step 1: Get the serverKey From the http://console.developers.google.com/ and write the server key as below.
Step 2: #define kGOOGLE_SERVER_KEY @"dsjfdsuiodfd...
How to get view controllers from navigation controller in swift
Hi Readers!
Please find below the code that you can use to get view controllers stack from Navigation Controller in swift.
var vc:NSMutableArray = ((navigationController?.viewControllers as! AnyObject) as! NSArray).mutableCopy() as! NSMuta...
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...
UIAlertController as an action sheet in iOS8 and above.
Now you can use UIAlertController as an actionsheet in iOS 8 and above versions. Here is an example of it:-
UIAlertController * view= [UIAlertController
alertControllerWithTitle:@"Sample"
...