Step 1
Create a new Project in X Code by selecting File --> New Project and then required optionsStep 2
Create a new File by selecting File --> new File --> CoCoa Touch Class.Select option of create Xib in the same window
Here three files will be generated sample.h , sample.m and sample.xib
Step 3
Sample.xib is like xml file in android.Open it and drag and drop the required component TextField
Step 4
Open the AppDelegate.m file then load the required Xib file (Sample.xib) in the didfinishlaunchingwithoptions method
If you run should be able to see the designed interface
Step 5
Create outlets by selecting a component in xib file and dragging it to the interface .h file
Step 6
We have to use TextField delegate UITextFieldDelegate to use the necessary methods of textfield like editing ,keyboard up down etc
Step 7
Implement the protocol UITextFieldDelegate in the .h file
like
@interface SampleController:UIViewController<UITextFieldDelegate>
Step 8
In SampleController.m you can use delegate methods
example
-(BOOL)
textFieldShouldReturn:(UITextField *)textfield
{
NSLog(@"entered text %@",self.nameTextView.text);
[self.nameTextView resignFirstResponder];
return YES;
}
Step 9
Create delegate and referencing delegate by selecting component in xib file and dragging it to the Files owner .Later right click it and create a referencing outlet
No comments:
Post a Comment