Changing image property upon button press - iphone

i have a UIImageView displayed in my view with an image "image1" already set.
I have a button below it.
During runtime i would like the image to change to "image 2" when the button is pressed and upon release i would like the image to display "image1" again
1) I know that i have to give the UIImage a label or something so that i can access it from xcode.
2) i know that i need to change the propery of the image upon press
3) i need to have an IBAction or something so that when i press the button it should change the property of the image to "image2"
BUT i dont know how to do this?
Can someone help please?

You need an outlet in your controller that is connected to the image view, so that the controller can find and message the image view. Check out this tutorial, and the Interface Builder documentation.

Related

Change background with an image stored in the iOS device on button's action

I'm developing a messaging app and I want to change the background image of the chat window on tapping the button (like Whatsapp) with an image stored in the device. Can anybody help me in writing code for that purpose?. Thanks!
First of all, you need to create a button, either from XIB/NIB or through code. On the action of that button, you need to change the background image of your view controller's view. Following code may be helpful for you.
-(void)changeBackgroundImage
{
self.objImageView.image = [UIImage imageNamed:#"imageName.png"];
}
objImageView is the object of UIImageView on which you have to show the image.
imageName.png is the name of the image which you want to show on the UIImageView.

Display a message when cursor over on UILabel

How can I display some text message when a label is tapped?
I have a label (Address).Now and when I tap over on it, I need to display the corresponding address in a small popup.
How can I do it?
I found out from your comment that you actually want to have a pop up on tap event.
All you need to do is
Have a button on the UILabel (on which you want to show pop up).
Make button of cutom type (It will make the button disappeared).
After that write a method to show pop up, and connect it to that custom button.
For creating a pop up, you can use UIView of desired size and position & make it appear/disappear on custom button tap event (touch up inside).
Hope this helps.

Adding a background image to UIBarButton Item using interface builder - Beginner

I added a UIToolBar from Interface builder, then dragged 2 UIBarButtonItem's. Now i need to add an image to it. So i selected the barButtonItem and selected the image using Interfacebuilder.
I only get a White image, with no curvy edge. My image is as follows. I don't see that image, but instead i see a white rectangle.
How do i prevent this. Can someone tell me whats wrong, and provide me with a working solution.
my bar button
If you go to iOS Human Interface Guidelines you will see the specifications for icons and buttons. This is my experience, for the best result you'd better create a specific icon (image) for UIBarButtonItem. If you still want to use an image, that doesn't follow the UIBarButtonItem guide, my approach is:
Add a generic UIButton instance to your view. Drag it from the list on the right to the view, not to the ToolBar or navBar.
Customize it with the image, i.e. from the Inspector, set the image or background image, or set it to custom style, bordered, etc.
Drag it to the toolBar, and XCode will adjust it. Again, it does not always guarantee the best result, but it does what you want.
I hope it helps.
You should drag an "Image View" on to your layout and specify the image in that - that worked for me, but I'm no xcode guru.
Hope that helps, Paul

Want to see the image only in iPhone

I have a button connected to an action.
When I set the background image on that button, the result is not visually appealing. I want just to see the image not the button but I want the ibaction functionality of that button.
Please help
You need a button with type UIButtonTypeCustom (this will stop the default button appearance from drawing). You can do this in interface builder or in code (although you can't change it once the button is initialized).

How To Create A Custom Center Tab Button?

I'm trying to follow this tutorial here to recreate a custom center tab button, but I already have my tabbarcontroller setup in IB. Can anyone help me do this? The tutorial does it all through code so its difficult to follow.
http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/
All they're doing is creating a blank UITabBarItem, no image or name, simply a placeholder. They then put a UIButton with a custom image (i.e. the green camera button) on top of the UITabBar. Just go into interface builder and add a new TabBarItem and put a UIButton on top of it.