Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 28, 2009, 09:04 AM   #1
Josh Kahane
macrumors 6502
 
Join Date: Aug 2006
Location: Suffolk, UK
Background Pic, Rotate, and Swap Image

Hi

So I have started making my first iPhone app! Its very, very simple, but I wan to slowly expand it. I need some help with a few things. Its really simple stuff, but I would really appreciate any help, thank you.

1. Firstly how can I set a background image? This is the first thing you see when you open the app.

2. I want this image to be able to rotate when I turn my device.

3. When I touch the screen I want the image to swap to my other chosen image.

Would appreciate the help, so far only have set the name and icon of my app.
Josh Kahane is offline   0 Reply With Quote
Old Apr 28, 2009, 02:41 PM   #2
iphonedevelop18
macrumors member
 
Join Date: Feb 2009
go into Interface builder, go into the library drag a UIImageView into your view. Go into the inspector, and then go to the tab with a ruler on it, see the picture next to the width and height click the two inside arrows so there highlighted,then unclick all of the outside I type lines, except the top one, so there not highlighted.go into the first tab on that screen change the image to whatever image you want to show first. Now quit IB. Go into xcode, under your .h view controller file create an IBOutlet for the image view like so
Code:
 IBOutlet UIImageView *myImage;
Now go into your .m file and look for the should autorotate method, you should see a
Code:
return (interfaceOrientation == UIInterfaceOrientationPortrait);
change that to
Code:
 return YES;
now build and go and it should show your image and rotate when you turn the simulator.
Hope this helps!
iphonedevelop18 is offline   0 Reply With Quote
Old Apr 28, 2009, 04:11 PM   #3
Josh Kahane
Thread Starter
macrumors 6502
 
Join Date: Aug 2006
Location: Suffolk, UK
This worked perfectly thanks, I now have my image on the screen and it rotates perfectly.

Next thing. How can I get it so that when my Finger is on the screen it swaps the image?
Josh Kahane is offline   0 Reply With Quote
Old Apr 28, 2009, 08:27 PM   #4
iphonedevelop18
macrumors member
 
Join Date: Feb 2009
Quote:
Originally Posted by Josh Kahane View Post
This worked perfectly thanks, I now have my image on the screen and it rotates perfectly.

Next thing. How can I get it so that when my Finger is on the screen it swaps the image?
Create a method in xcode (.h view controller file) for the button you'll add later, like so.
Code:
 - (IBAction)bgClick:(id)sender;
also add it into your .m file
Code:
 - (IBAction)bgClick:(id)sender {
        myImage.image = [UIImage imagenamed:@"MyOtherImage.png"];
}
Go into interface builder and add a UIButton to fill the whole screen go to the first tab and make it a custom button. Go into the files owner and connections tab in that and connect your method to the button. After doing that it should all work.

I strongly recommend you either get a book or watch some tutorials from these sites, as this is very basic stuff.

http://www.iphonedevcentral.org/view...ewAll&number=1

http://icodeblog.com/
iphonedevelop18 is offline   0 Reply With Quote
Old Apr 29, 2009, 02:28 AM   #5
Josh Kahane
Thread Starter
macrumors 6502
 
Join Date: Aug 2006
Location: Suffolk, UK
Ok thats fair enough I was struggling with getting through books etc so I though I'd try and throw myself in but clearly I am getting to much help with the simplest things, but I appreciate your help so far your code has been working well, except for one thing.

I did what you said but firstly I have entered the code, and tried to connect that thing to the button in IB but I cant connect anything to the button. Secondly, I thought I'd see whats wrong by Building and going and its revealed errors, a couple I fixed but there are too I cant see whats wrong.

Well Im going to try and run through your instructions again, if that doesn't work I'll give it a break and try learn it the proper way. Thanks.
Josh Kahane is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
combine a background image, another image and a video in iMovie 10? MacMan988 Digital Video 0 Oct 27, 2013 04:52 AM
Background pic on ipod touch 5 BradOntCa iPod touch 5 Jan 3, 2013 06:51 AM
Rotate Image Inwards AFPoster Design and Graphics 6 Dec 27, 2012 02:16 PM
Background Image rheb1026 iPhone/iPad Programming 2 Jul 29, 2012 10:24 PM
Desktop background pic sizing, frustrating. Gaprofitt Mac Basics and Help 1 Jun 23, 2012 07:16 PM

Forum Jump

All times are GMT -5. The time now is 04:21 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC