views:

59

answers:

1

I am new to iphone development.I have created a map application.I have created a tool bar below the mapview.When i click the button on the tool bar it should display an alert view asking to set the current location .How can i achieve it.please guide me .Where should i give method for the button click event.I have created the toolbar in interface builder.Please help me out.Thanks.

+1  A: 

The method should go in the controller associated with XIB (pronounced NIB) file. In the header of that controller you will declare a method such as

-(IBAction) userPressedButton:(id) sender;

Save the .h, and return to InterfaceBuilder, select your button and press cmd-2 to show the inspector for outlets. Drag "Touch Up Inside" to File Owner in the window countaining the icons. That FileOwner object is your controller. When you let go it will pop-up a menu of all of the Actions in the controller, so you should see your userPressedButton method. Click that.

Then in the implementation (.m) file you, well, implement that method to do whatever you want such as display an AlertView etc. Basically the XIB's file owner is the controller class, and you've just told IB that when a finger is lifted up inside the area of your button, it should call the userPressedButton method.

Simples ;-) It's strange to start with, then wonderful.

buggles