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

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...

How to resolve JQuery Lightbox session object access issue for iPhone ?

Hiii all... I have found something about iPhone and Jquery lightbox. It would be beneficial for those who are working with Jquery lightbox. If you are opening .aspx page in lightbox, and fetching few values from Session object in backend, ...

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:@...

Play videos sequentially using MPMoviePlayerController

Hello All, Sometime we want to play all videos of gallery sequentially. These lines of code will help you to play videos sequentially using MPMoviePlayerController.it worked for me. In .h file.. MPMoviePlayerController *moviePlayer; in...

To check that internet is available or not.

Hi Friends, sometimes we face problem in internet connectivity, With the following lines of code we can check whether we are connected to internet or not. - (BOOL)isNetworkAvailable { CFNetDiagnosticRef dReference; dReference = CFNe...

Draw a route between two annotation point on MKMapView

The following lines of code helped me to draw a route between two Annotation point in MKMapView Hope this will help you in your coding CSRouteAnnotation* routeAnnotation = (CSRouteAnnotation*)self.routeView.annotation; // only draw o...

How to encode and decode NSString

Following method will encode and decode NSString. Characters to leave unescaped (NULL = all escaped sequences are replaced). - (NSString *)URLEncodedString { CFStringRef url = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (...

How to get sorted NSArray of date for NSDictionary.

With the help of following code you can sort the given dictionary containing key as Date. @implementation NSMutableDictionary (SortingNSMutableDictionary) -(NSArray *)getAllSortedKeys{ NSMutableArray *array = [NSMutableArray arrayWithA...

How to check the Network availability for 3G and 4G connection

Following code will help in you to check the network availability for 3G and 4G connection const char *host&#95;name = "google.com"; BOOL _isDataSourceAvailable = NO; Boolean success; //Creates a reachability reference to ...

Passing extra data with push notification

Sometime we do need to send additional data while sending Push-notification on iPhone , this can be easily achieved by adding following line to your code. But one should keep in mind that apple does have a limitation of 144 character while sendin...

How to create dynamic UITableViewCell for Chat

Following code will help you to create dynamic UITableViewCell w.r.t to its content of message. -(void)setChatData:(ChatMessage *)messageObj memberDict:(NSDictionary *)memberDict isCurrentUser:(BOOL)isCurrentUser{ NSDictionary *user...

How to add Twitter account in your iPhone

The following code will help you to create your twitter account in your iPhone through coding. Also please note this code will only run in ios7 or later. -(void)createTwitterAccount{ ACAccountStore *store = [[ACAccountStore alloc]init]...

How to calculate distance from CLLocationCoordinate2D

Using the following code we can calculate the distance between two CLLocationCoordinate2D. +(double)calculateDistance:(CLLocationCoordinate2D) f to: (CLLocationCoordinate2D) t { // CLLocation *locA = [[CLLocation alloc] initWithLati...

Tabbar Customization

Snippet works all around to customize the tabbar icons & texts display color for selected and unselected state for iOS7 self.tabbarController.tabBar.tintColor = [UIColor greenColor]; Below code can be used to customize the text look. ...

How to save or delete caf file from NSDocumentDirectory

Follow these two methods to save or delete your .caf file from NSDocumentDirectory. -(NSString *)saveFileWithOldName:(NSString*)oldNameStr { NSArray *dirPaths; NSString *docsDirs; NSString *tempStr2; dirPaths = NSSearchPa...

How to register your app on facebook

Please follow these simple step to register your app on facebook Open Developer account from your Facebook. Select "Create App" you'll be directed to a page where number of options will be available at the top bar. One can reach there by j...

Fetch All Notifications

Snippet to fetch all local notifications of the app. One can customize any notification and cancel the same. UIApplication *app = [UIApplication sharedApplication]; NSArray *eventArray = [app scheduledLocalNotifications]; for (int ...

How to display phone book contacts in iphone through coding

The following code will present viewController which will show all the contacts of phone book Please do add Addressbook.framework in your code. Also import AddressBookUI file to use the following code. ABPeoplePickerNavigationController *pic...

How to save file in document dicretory

Following code will help you to add or delete file from document directory. -(NSString *)saveFileWithOldName:(NSString*)oldNameStr { NSArray *dirPaths; NSString *docsDirs; NSString *tempStr2; dirPaths = NSSearchPathForDire...

How to get Cookies from UIWebview

The following code will get the cookies form the sever and will store in the array. Get the appropriate cookie from the array by its name. - (void)webViewDidFinishLoad:(UIWebView *)webView { NSHTTPCookieStorage *storage = [NSHTTPCookie...

How to validate that string is email address or not.

During User registration it is very necessary to check that entered email id is valid or not. To check that following code will help you. - (BOOL)validateEmailWithString:(NSString*)email { NSString *emailRegex = @"[A-Z0-9a-z.&#95;%+-...

How to use search bar in UITableView

This is very helpful, if you want to use search functionality on UITableView. Code for ViewController.h @interface ViewController : UIViewController<UISearchBarDelegate,UITableViewDataSource,UITableViewDelegate,UISearchDisplayDelegate&g...

How to save and access value from NSUserDefaults

NSUserDefaults is very useful, if you want to save less data and want to access that data whenever you open the application. This data does not delete even after closing the app. To save data in NSUserDefaults NSUserDefaults *usr = [NSUser...

To perform a real-time capture

To perform a real-time capture, a client may instantiate AVCaptureSession and add appropriate AVCaptureInputs, such as AVCaptureDeviceInput, and outputs, such as AVCaptureMovieFileOutput. [AVCaptureSession startRunning] starts the flow ...

Some necessary information to publish the application to app store

To submit an application to the App Store, you need to create an iOS provisioning profile for distribution (App should be signed with these certificate) for that you have to be a member of the iOS Developer Program. Note: iTunes Connect does n...

How to handle UIPanGestureRecognizer and moving your all images w.r.t moving image.

The following code help your image to move using UIPanGestureRecognizer. While moving your selected image other images set there location automatically. -(void)addImageToScrollView { float x=5,y=40,width = 100,height = 100,spaceH = 5...

Create audio file manually

We often come across conditions where manual audio file is to be created. For example recording an audio or download audio data from server. These all need audio file in which data is to be populated. Below, I'm creating an sound.caf file and...

IPhone alert view

To show alert view in IPhone, the following snippet will help you. UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Message" message:@"Network error. Try again?" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil]; ...

Handling audio files in iOS 7

The general idea for playing an audio file in iOS 6 was to create an object of AVAudioPlayer and pass the file path to it as follows: NSURL *fileURL = [NSURL fileURLWithPath:audioFilePath]; player = [[AVAudioPlayer alloc] initWithCont...

Get a rotated image

A very good stuff that allows you to get rotated image. Sometimes we rotate the UIImageView, it appears like image is rotated but in actual it's the UIImageView which is being rotated. If we try to fetch the image from rotated UIImageView it will...

Change background and font of UIWebView

To change the Background color, Font color, Font style in UIwebview, follow the following line of code. [webview loadHTMLString:[NSString stringWithFormat:@"<html><body style=\"background-color: red; font-size: 15; font-family: Helvet...

Date/Time Operations in php

Sometime there is a need to perform different operation on dates for ex: You may need to : 1) Add two dates/time 2) Subtract two dates/times for ex- to calculate your age by deducting your date of birth from current date. And many m...
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: