About Me

My photo
I am computer Engineer.I like mobile technology so much.Currently i am iphone app developer.I have seen many blogs and sites they help me very much to solve my problems in coding and as a new comers in any tech require help to solve problems.I like to help those and i have started this blog.

Amazon Contextual Product Ads

Free call to anywhere in india

All of us have mobile to call anywhere in india.But as we all there is charges per call depend on SIM card you are using and sometimes there is roaming charges also applied if you are in another state in india.

Mostly i use this web call to make call to friends.

Here is website to call free anywhere.
http://www.mobivox.comIt allow you for 10 minutes to call.

In this,there is steps you have to follow

1)go to http://www.mobivox.com

2)Register Mobile number,email-id,enter your pin code.
Note:here mobile number is from which you have to call

AFNetworking POST and GET

#import "AFHTTPRequestOperationManager.h"

///Post

AFHTTPRequestOperationManager *manager =
    [AFHTTPRequestOperationManager manager];
    
    manager.responseSerializer.acceptableContentTypes =
    [NSSet setWithObject:@"text/html"];
    
    
    
    NSDictionary *parameters = @{@"old_password" : @"test",
                                 @"new_password" : @"test1",
                                 @"user_id" : @"1"
                                 };
    
    
    [manager POST:@"hhtp://your url"
       parameters:parameters
          success:^(AFHTTPRequestOperation *operation, id responseObject) {
              NSLog(@" JSON: %@ ", responseObject);
              //       NSDictionary *responseJSONObj =[NSJSONSerialization
              // JSONObjectWithData:responseObj];
              
              NSLog(@"result:%@", [responseObject objectForKey:@"result"]);
              
              
          }
          failure:^(AFHTTPRequestOperation *operation,
                    NSError *error) {
              NSLog(@"error %@,", error);
              
              

          }];



//GEt

AFHTTPRequestOperationManager *manager =
    [AFHTTPRequestOperationManager manager];
    
    manager.responseSerializer.acceptableContentTypes =
    [NSSet setWithObject:@"text/html"];

[manager GET:@"hhtp://your url"
       parameters:nil
          success:^(AFHTTPRequestOperation *operation, id responseObject) {
              NSLog(@" JSON: %@ ", responseObject);
              //       NSDictionary *responseJSONObj =[NSJSONSerialization
              // JSONObjectWithData:responseObj];
              
              NSLog(@"result:%@", [responseObject objectForKey:@"result"]);
              
              
          }
          failure:^(AFHTTPRequestOperation *operation,
                    NSError *error) {
              NSLog(@"error %@,", error);
              
              
          }];



///for xml,plisr

Login module Auto Layout for iOS 8 with iOS 7

In this article, I am going to share a few common layouts, scenarios and problems that I am facing when I am developing the iOS app using the Auto Layout. I am going to show the techniques to link different objects together using constraints inside the same view controller.

Auto Layout for iOS 8 versus iOS 7

I believe most iOS developers will still include iOS 7 under their development plan. So before getting started, it is good to know the differences between Autolayout in iOS 7 compare with iOS 8.
One of new things in iOS 8 is the Layout Margin. Layout Margin is a new propertyavailable in UIView for iOS 8. So, any objects inherit from UIView will have this property. If you are developing the app for both iOS 7 and iOS 8, you should not use Layout Margin (or use layout margin in a smart way).
So, if you have any constraints related to layout margin and you didn’t do a proper check before launching the app on iOS 7 devices, the app might crash or the arrangement of the objects might be out of order.
Whenever you are trying to add new constraints from the storyboard in XCode 6, “Constrain to Margins” is ticked by default as show as the screen shot below. The meaning of this selection is to add constraints with the new property in iOS 8.
Constrain to Margins iOS 8
If the deployment target of your app is iOS 7 and above and any of your constraints have this layout margin, the XCode will complain with the warning “Layout attributes relative to the layout margin on iOS prior to 8.0″.
Layout attributes relative to the layout margin on iOS prior to 8.0 warning
If you are developing the app for both iOS 7 and 8, it is best to “Untick” theConstrain to Margins.

How to use Auto Layout with more than One Object

Using the autolayout constraints with more than one object inside the same view controller can be tricky.
You may ask yourself some questions when you are deciding the design before trying to link the objects together inside the view controller:-
1. How many objects are inside the view controller?
2. Is the object fixed in height or have flexible height?
3. Is the object fixed in width or have flexible width?
4. How would the object be positioned inside the view controller. (Eg: Stick on the top of the view controller)
5. What is the relationship between Object A and object B? (eg: The Object B is positioned on the Right of the Object A)
Example:-
Let’s say I have a view controller with 2 Text Fields (Email and Password) and one Login Button.
Here is my decision:-
1. Both the Text Fields have fixed height (50 px) but with flexible width.
2. There will be a Navigation Controller on the top of the View Controller.
Decision on EmailTextField
- The Top of the First Text Field (EmailTextField) will stick to the Top Layout Guide of the Navigation Controller
- The Left of the EmailTextField will stick to the Left Side of the Superview (Leading Space)
- The Right of the EmailTextField will stick to the Right Side of the Superview (Trailing Space)
So, there are 4 constraints that I will have to associate with this EmailTextField object. The below screen shot shows the 4 constraints:-
Auto Layout with more than One Object1
If you do it correctly, You will see 4 constraints on the Size Inspector and also theDocument Outline like the screen shot below.
Auto Layout with more than One Object2
Next, I want to add the PasswordTextField onto the screen. I will position it on the bottom of the EmailTextField.
Decision on PasswordTextField
- The Top of the First Text Field (EmailTextField) will stick to the Bottom of the EmailTextField.
- The Left of the PasswordTextField will stick to the Left Side of the Superview.
- The Right of the PasswordTextField will stick to the Right Side of the Superview.
Here is screen shot for adding the constraints for the PasswordTextField.
Auto Layout with more than One Object3
If you do it correctly, you will see that the Top Space of the PasswordTextField is Linked to the Bottom Space of the EmailTextField like the screen shot below:-
Auto Layout with more than One Object4
IMPORTANT TIP: Double Click on the constraint on the Size Inspector to view the detailed relationship of the constraint.
Finally, let’s link the constraints for the last object – the login button.
Decision on the Login Button
- The button has fixed height: 60 px
- It will stick on the bottom of the view controller with constant: 20 px (distance)
- There will be constant 16 px on the Left and Right of the superview
Auto Layout with more than One Object5
The above auto layout guide for multiple objects inside the same view controller is very straight forward because the top objects (EmailTextField,PasswordTextField) does not have any relationship with the bottom object (Login Button).
The autolayout will become more complicated when you want to add a UIScrollView and links all the objects together.

How to use UIScrollView with Auto Layout

Using the Auto Layout with UIScrollView can be tricky. I personally having a tough time with ScrollView when I first started learning Auto Layout. After some trials and errors for a few weeks, I almost got it right.
The most basic rule of using ScrollView with Auto Layout is you will have to set up the constraints from the top of the ScrollView to the bottom of the Scrollview and from the left to the Right. You can not have any missing link neither the horizontal nor the vertical layout. Or else the XCode will complaint!
Let’s just use the same example as the above and we will add all the 3 objects inside the UIScrollView.
First of all, we will have to add the scrollview onto the empty View Controller inside the Storyboard. For my personal preference, I would stick the top of the ScrollView on the top layout guide and not under the UINavigationBar. Remember, the Scrollview will always have flexible height and flexible width.
Autolayout with Scrollview1
If you do it correctly, you will see that the leading and the trailing space to the super view will be 0, the bottom space to the bottom layout guide is 0 and also the top space to the top layout guide would be 0 as well like screen shot below:-
Autolayout with Scrollview2
Next, putting the 2 text fields and also the login button inside the scrollview. If I connect the constraints exactly like the first example that I showed above. The XCode will complaint. The reason is adding a scrollview will change the behaviour of the Autolayout.
The common complaints:
1. Frame for “XXX” will be different during run time.
To Solve it: Add another constraint to align the object to the center of the superview (ScrollView)
Autolayout with Scrollview3
Autolayout with Scrollview4
2. The Views are vertically ambiguous or (Scroll View has Ambiguous scrollable content height)
To solve it: Link the objects from the top to the Bottom of the Scrollview (No missing relationship in the middle)
For the above case, I will make another constraint (Horizontal Center in Contrainer) to centrelize the EmailTextField. And then “Control Drag” to link up PasswordTextField with LoginButton with a vertical space.
Autolayout with Scrollview5
The XCode will love you by adding the 2 extra constraints and stop complaining.

How to Resolve Conflict Constraints and Other Autolayout Errors/Warning

Here are some of the common AutoLayout Errors/Warnings:-
Warning #1Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

Description: This only happens when your app has to support iOS 7 and the app have UILabel on one of your View Controller Objects inside the storyboard. And you didn’t tick “Explicit” on the “Preferred Width”.
How to Resolve this issue?
A. If you know where to locate the specific UILabel, just select the UILabel Object on the Storyboard. Then, Make sure that “Explicit” is ticked. If you do not want to have a fixed width, just assign the value as 0 (zero). The width for the UILabel will be based on the other connected constraints for this UILabel.
Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
B. When your storyboard has many view controllers objects and also many UILabel, you may find it hard to locate the specific UILabel object. So, you will have to use the following steps in order to location the UILabel.

Resolve the Automatic Preferred Max Layout Width Warning From SourceCode

1. Right Click the Storyboard and “Open As” -> “Source Code”
2. Use the keyboard Key (Command + F) or Click “Find” -> “Find” on the Navigation bar of the XCode to launch the Search Window. Paste the code
into the Find Window.
3. Click the Search Icon then Select “Edit Find Options”.
4. Then, Choose “Regular Expression”.
5. The Find Window will show you all the UILabel does not have preferred Layout Width. You will have to paste
into all the UILabel like below screen shot until the count for the Find Window is 0.
6. Lastly, you will have to Open the Storyboard again. This time choose “Interface Builder – Storyboard”.
The above steps will solve all the Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0 warnings.
Warning #2: Frame for “xxx” will be different at run time.
Description: This warning is letting you know that the frame for the object inside the storyboard does not match with the constraints that you connected on that object.
How to Resolve this issue?
Most of the time, this issue can be solved easily by going to the “Resolve Auto Layout Issue” tab and choose either “Update Frames” or “Update Constraints”.
Update Constraints
Sometimes, you may face a situation where the view controller has multiple Auto Layout Warnings. You may have already spend some time to fix the issue but the issue is too complicated that you might not be able to fix easily.
From my own experience in a situation like this, it is better to clear all the constraints for all the views inside the view controller. And then reconnect the constraints all over again for all the views. The chance is that after you reconnecting the constraints, you would not see the issue again.
Clear Constraints for all the views

How to install Pod file in xcode project

Steps to install cocoa pods in system and project




1) sudo gem install cocoapods

//Note : Your project is created in Desktop..

2)cd Desktop
3)cd DemoPodFile

//////
If Project is in Mac HardDrive then

2)cd /volumes
3)cd “Mac HD”  /// name of your HD( use “ for space in name)
4) cd “Bhoomi Work”  ///Folder Name
5) cd “”Project Name”


//////          
4)pod setup
5)vim PodFile

   In this press i to go to insert mod  write following command


platform :ios, "7.0"
pod 'ASIHTTPRequest'

//// which install latest version of AFNetworking


///// Now exit from insert mode Press ‘Esc ’ key
//// write command  :wq

6)pod install



 

Handy key points to remember in ios


  ..........................................................................................................1 )  ////when type in textfield ,according to text it should display data using predicate......

You have give IBAction in xib in textfield for Editing Changed...................

-(IBAction)editingChnageMethodOfTextField
{
   [self  valuseChanged];
}


-(void)valuseChanged
{
    ///////
    if ([txtSearchBar.text isEqualToString:@""] || [txtSearchBar.text length] == 0)
        {
            [self textFieldShouldClear:txtSearchBar];
        }
    //name contains[c] %@", searchText
   
   
        tv_main.hidden=FALSE;
     noDAtaLbl.hidden=TRUE;
     self.arrHouse=nil;
     self.arrHouse=arrHouseCopy;
     // //NSLog(@"arrhouse---%@",arrHouse);
    
////// use prediction to filter array for  key design_name_ar=@""....................................

     NSArray *temp=[self.allDBDataArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"design_name_ar contains[c] %@",txtSearchBar.text]];
    
     if ([txtSearchBar.text isEqualToString:@""] || [txtSearchBar.text length] == 0) {
    
     [self performSelector:@selector(dissmiss) withObject:nil afterDelay:0.2];
    
    
     }else{
     if (temp.count==0) {
    
     tv_main.hidden=TRUE;
     noDAtaLbl.hidden=FALSE;
     }
    
     self.arrHouse=[[NSMutableArray alloc]initWithArray:temp];
     //        //NSLog(@"array value--%@",self.arrHouse);
    
    
    
     //  //NSLog(@"val--%@",txtSearchBar.text);
     }
    
     txtSearchBar.returnKeyType=UIReturnKeySearch;
    
    
     [tv_main reloadData];
    
}


















  ..........................................................................................................

2)    //////// use dispatch async to fetch data from url............

 #define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)

NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"url string"]];
    NSData* data = [NSData dataWithContentsOfURL: url];
    NSLog(@"url--%@",url);
   
    dispatch_async(kBgQueue, ^{
      
        [self performSelectorOnMainThread:@selector(fetchedData1:) withObject:data waitUntilDone:NO];
    });

- (void)fetchedData1:(NSData *)responseData
{
}



  ..........................................................................................................

3) To compare version of ios........................



#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)






 /////// use like this.........
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
        [self shouldAutorotate];
        [self updateLayoutForNewOrientation: self.interfaceOrientation];
       
    }


..........................................................................................................


4) use .pch file to import all header files...........

To make .pch  file go  to New File-->Ios-->c++-->pch File......

Now goto Build setting-->Prefix Header.......... write Project Name/Pch file Name.pch

Now import all header files.........


like this.......

#ifndef Product_Catalog_PrefixHeader_pch
#define Product_Catalog_PrefixHeader_pch
#import <Availability.h>
#import "Globals.h"

// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
#import "Product.h"
#import "ProductListViewController.h"
#import "ProductListCellTableViewCell.h"
#import "AppDelegate.h"

#endif
..........................................................................................................

#pragma mark webservice for login
-(void)webServiceForConfigFile
{
   
    NSString *serviceString=[[NSString stringWithFormat:@"%@",CONFIG_URL] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *serviceURL=[NSURL URLWithString:serviceString];
    ASIFormDataRequest *downloadRequest = [ASIFormDataRequest requestWithURL:serviceURL];
    downloadRequest.timeOutSeconds = 60;
    downloadRequest.delegate=self;
    [downloadRequest setShowAccurateProgress:YES];
    [downloadRequest setShouldContinueWhenAppEntersBackground:YES];
    downloadRequest.tag=ConfigFile_TAG;
    //[downloadRequest addRequestHeader:@"password" value:PASSWORD];
    [downloadRequest setRequestMethod:@"GET"];
    [downloadRequest setDidFailSelector:@selector(failRequest:)];
    [downloadRequest setDidFinishSelector:@selector(completeRequest:)];
    [downloadRequest startAsynchronous];
   
}



How to upload video on Youtube

link :

https://github.com/surajwebo/YouTubeUploadVideo

To hide keyboard from whole application

[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More