Show Text On Label With The Help Of Button in IPhone/iPad
In this article I will explain how to show text in a label when a button is clicked in an iPhone or iPad.
In this article we create a single-view application. Here we use one label and three buttons using xib (XCode Interface Builder). In this app, when we click on the first button, the button title color changes and it shows text in the label. The same happens when we click on the second button; the button title color changes and it shows other text in the label, as it is when we click on third button, where again the button title color changes and it shows other text on the label.
Open XCode by double-clicking on it.
Create a New XCode Project via clicking on it.
Now select "Single View Application" and click on Next.
Now give your Product Name. Here I use UIView and Company Identifier Mcn Solutions and click on Next.
Select the location where you want to save your project and click on Create.
Now you will see in the XCode Window six Objective C Classes generated by XCode. When we use a Single View Application, ViewController automatically generate ViewController.h, ViewController.m class or xib correspondence to iPhone/iPad.
Here we write code only in the View Controller class.
Click on the File owner icon
Connect the button to it's object via linking
As it is done for iPad:
Select action touch up inside
Select which platform you want to see the output for.
Output 1 in iPhone:
Output 2 in iPhone:
Output 3 in iPhone:
Output 4 in iPhone:
Output 1 in iPad:
Output 2 in iPad:
Output 3 in iPad:
Output 4 in iPad: