How to add a simple UIButton in a UIView by coding?


This post deals with adding a button in UIView by coding…

Create a button

 

UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];

button1.frame = CGRectMake(x, y, width, height);

where x and y are coordinates

width is width of the button,height is height of the button

[button1 setTitle:@"Hello" forState:UIControlStateNormal];

 

Add the button to parent view

[[self view] addSubview:button1];

How to pass a value from one UIViewController to another UIViewController?

This post deals with passing of an integer value from one

UIViewController class to another UIViewController class…

Suppose there are two UIViewController classes

FirstViewController

SecondViewController

 

Now we have to pass an integer value from FirstViewController to SecondViewController

We can use @property to pass values from one class to another but the problem is that the property can be a object only

So we will have to use NSNumber object to store int value as an object and later use it as a property

 

In the SecondViewController.h file

write

NSNumber *value;

@property(nonatomic,retain) NSNumber *value;

In the SecondViewController.m file

@synthesize value; after @implementation

In the FirstViewController.m file

SecondViewController *second=[[SecondViewController alloc] initWithNibName:@”SecondViewController” bundle:nil];
testing.value=[NSNumber numberWithInt:9];

Don’t forget to include SecondViewController.h file in the FirstViewController.h file.

Now in SecondViewController.h file access the value of property by

 

[self.value intValue]

How to know which UIButton was pressed?

How to know which UIButton is pressed when

there are more than one UIButton in a view?

 

Suppose there are two buttons in a view

Now in the identity inspector window for button0 set the tag value=0

Set the tag value for button1 as 1 in the same way as for button0

 

Now here is the coding part

Link the following method with both the buttons in the Interface Builder

-(IBAction)action:(id)sender
{
if ([sender tag]==0) {
NSLog(@"button0");
}
else
{
NSLog(@"button1");
}
}

Here sender gets the identity of the button object which is pressed.

By usingĀ  [sender tag] we get to know which button was pressed.

Same thing applies for more than two buttons provided different tag values should be used for each UIButton object.

The new Xcode 4 – Intelligent enough!

The new Xcode 4 – Intelligent enough!

Apple has launched the new Xcode 4 for the iOS Application Developers. It is for sure that the developers are going to love it because of its awesome features. Lets have a look at some of its new features.

What’s new in Xcode 4

 

The tools in Xcode 4 are redesigned to work faster and smoother. It has become more helpful, and it not only tells you error but also fix it for you.

 

Some of the new features which you will notice at first….

 

Single Window

Yes, the Xcode 4 is a single window development environment which combines Interface builder in the same window in which you write code.

 

Interface Builder is Built-in

There is no seperate application called interface builder. Infact, interface builder is integrated with Xcode. Selecting a .xib file will directly open editor in Xcode. You can drag connections directly from UI design to source code. If your code is not ready with actions and outlets then just drag connection to empty space in source code and Xcode 4 will define outlets and actions for you.

 

Assistant

This is another useful addition in Xcode4. If you make some changes in a source file then assistant will help you in determining which other source files need to be checked, as you work.

 

Fix it

The Xcode 4 is an IDE which is intelligent enough, not only to report but also fix problem for you.

How to create iPhone/iPad applications and submit them to App Store

How to create iPhone/iPad applications and submit them to App Store

So today we are going to see how to create iPhone/iPad applications and then submit them to App Store. So basically we will be starting with the requirements first that we need to get us started.

Requirements for building iPhone application

 

Macintosh computer

You can build an iPhone application only on a Macintosh computer. Macintosh computers run Mac as their operating system, and are completely different from Windows. You cannot install Mac operating system on a Windows PC as it is hardware dependent. So guys if you own a Windows computer then get ready to shed some money for buying your new Mac. You will feel the difference between them from the day you start using Mac.

 

Xcode

Xcode is an integrated development environment developed by Apple. Applications for iPhone/iPad are developed using Xcode in Objective c language. You can download Xcode by registering on Apple’s developer website. Xcode is downloaded as a complete package which consists of a programming environment for writing codes, an Interface Builder for designing pages and an iPhone simulator for testing applications.

 

 

 

iOS Developer Program

Ok, this is not so good part as it involves some more expenditure after you buy your Macbook. Apple needs you to be enrolled in its developer program before you can start putting applications on app store for sale. There are two membership programs, depending on whether you are a company(iOS Developer program Enterprise – $299) or an individual(iOS Developer Program Standard – $99) you can select your membership. After you get registered you can submit your application for sale on app store.

 

 

Apple’s new iPad2 | Thinner, Lighter and full of great ideas

Apple’s new iPad2 | Thinner, Lighter and full of great ideas

Thinner, Lighter and full of great ideas

 

Hi guys, it seems that Steve Jobs went strict on iPad’s dieting schedule, the result is in front of us. iPad2 has got rid of those extra flanks. Well, after seeing it one can only say……How the hell it holds equipments which give us such a smooth performance, even better than its elder brother. Yes, you heard it right, it is 3 times slimmer and more powerful than iPad1. Infact, iPad2 is the slimmest tablet in the world and is powerful than every other tablet .Well, we don’t know about humans, but if we believe Apple Inc. then “Thinnest is the Fittest”.

 

Lets check out some of the new features added to iPad2….


Dual-core A5 chip

Two cores in one chip, means it can do twice the work
at once. It multitasks smoother and applications work
better.

 

 

Superfast graphics

With up to nine times increase in graphics power , game
playing and video viewing on iPad is smoother and more
realistic.

 

 

Two cameras

Designed for Facetime video calling so that you could
see your friend laughing from front camera, and share
your environment from the back camera.