skip to main | skip to sidebar

Thursday, December 30, 2010

Adding UIButton in the View

0 comments
Here is on how to add a button using the Interface Builder.





1. In Xcode in the Groups & File expand the Interface Builder Files (IB) then double click on the NIB file that defines the view to which view you want to add a button.













2. In IB, select Tools -> Library and drag a UIButton to the view. Resize the button and double click inside to put title "My Button".













3. Go back to Xcode and on your .h file write this code

-(IBAction)mybutton;








4. Back to IB then in File's owner under Receive Action connect "mybutton" on the UIButton that you created earlier.














5. choose the "Touch up Inside option".











6. In Xcode in your .m file insert this code

-(IBAction) mybutton{
    
            NSLog(@"My button is now Working!");
}



then Build and Run.






7. When you hit the button on the simulator the response appear on the debugger Console ("My button is now Working").

Tuesday, December 28, 2010

Your First iPhone App - Hello iPhone project

2 comments



Lets start the first tutorial, we are going to create our first project the hello iPhone project. In the first tutorial your going to run your Xcode first and now that the Xcode running, create a new Xcode project.









Select File -> New Project... then it launch the New Project Wizard. Select iOS and choose the View-based Application template and hit the choose button. Then name your project as Hello_Iphone.





The Xcode Project Window will open, on the left side of the window you see the organizational groups under Classes, are the classes you will be working with. Under the Resources folder double click Hello_IphoneViewController.xib to open the another tools. Interface Builder (IB) as the name to implies, use to create the visual interface enable users to interact with.





In Interface Builder you could see the View and Library Window (if you don't see the library window you can select Tools -> Library on the Interface Builder menu). Find a label on the Library Window then Drag it to the View.








Double click the label that you drag into View, then type Hello iPhone. Make sure to center it









Let's add more things here in your Inspector Window you can customize the text, to show your Inspector window jus select Tools -> Inspector. if you want to change the Font Size, on the Menu bar Select Font -> Show Fonts and you can also change font-type . if your done for that then save your work File -> Save, Quit Interface Builder. Go to Xcode on Xcode Toolbar do Build and run.







The output appear on the Simulator.
Congratulation you finish your first App.