Using One UIImageView that Changes Based on Button Pushed - ios5

This is a very basic question, but I cannot figure this out. I'm new to iOS/XCode. I've gone through a few tutorials that somewhat covered this (but a little more complex). I have an Android app that I'm trying to port over to iOS. I'm using storyboards for this app.
The basic premise is that the app contains 27 thumbnail/full images. For this question, we'll say the 27 pictures are split into 4 categories: cats, dogs, sharks, whales. Currently, I have the app launching with Navigation Controller w/ View that shows 4 Buttons with these categories. These push out to 4 separate view controllers each set up with buttons with the thumbnail as the image. I want to select the thumbnail and show a scene with the full image. I only want one full image view controller with a UIImageView in it that will display the full image of the thumbnail pressed. (Using table views may be easier, but I want to control the user interface and have more than just a rows of items to select.) Also, I'm not sure if this matters in the eventual set up, but from the full image scene I will want to add a play button that will play a local mp4 file (but that's for another day).
The image set will remain static so I was trying to incorporate NSArray with the full image name stored. I believe I have to add a file that is subclass of ViewController and incorporate code that will take on the full image file name based on the button pushed. This is where I'm stuck. In java for Android, I just had listeners on each button and used a case statement to set the full image variable and passed it to my full image class/xml.
Another option I think I remember seeing somewhere is I could use the title of each button and enter the full image name there. Then when the button is pressed, the title is passed to the full image view. I think this eliminates the need for an array (???).
Any help is appreciated.
Thanks,
Jason

Related

Application walkthrough when opened for the first time

How do you setup in your application to show little bubbles with text and block the rest of the screen from being used and only allow a small section / button to be pressed. I am wanting to create a walkthrough to show users how to use the application and where to find things within the application when it is opened for the first time.
I would like to dim the rest of the application except for the part I want them to click on. Is there a framework already with these features?
There's no frameworks that provide this functionality, as far as I know.
One way you could do this though is to have a set of overlay images which you overlay over the whole screen the first time the user goes to that screen. To determine if the user has already been to a screen, I suggest you look at NSUserDefaults. To create the overlay images, I'd make the image the full size of the screen (i.e. 460x320 if you are showing the status bar) and then have transparent sections where you want to "see through" to the element below. Add a gesture recogniser to the overlaid image view to detect a tap and then hide the image and set the flag in NSUserDefaults to make it not happen the next time the user goes to that screen.
If you don't get a better answer, you could look at MAAttachedWindow on the page at this link. It's written for Cocoa, not Cocoa Touch, so you would have to convert it. I am considering doing this myself. You might find it to be worth the trouble, but I haven't looked at every detail, yet, so I couldn't say for sure. There are only tow files that are involved (.m and .h).

Navigation based iPhone app using thumbnails

I've been searching the internet for quite some time and didn't find anything useful.
I want to make a basic app for the iPhone using simple views and hierarchical data nothing too fancy. The only problem is that I can't seem to find any tutorial that makes the first/main view like a thumbnail gallery that leads to other views.
To clear it a bit up:
I want my first view to be a 2D array of thumbnails and a little text below each of these thumbnails. When I click on a thumbnail it takes me to a sub-view containing more detailed info and options.
So is there any relatively painless way to make something like this using Table Views or something like that or do I have to make a custom view with methods to populate it as my heart pleases.
Please take note that I want to avoid any third party libraries like Three20 or similar.
Thanks
Just to make sure I understand, you want to make an application that acts similar to the Contacts on the iPhone? In other words, a list that when an item is clicked will take you to a new view with detailed information about the clicked item? But in your case, you want an image next to/above the text?
In either case, you will want to use a tableView. If you want an image beside the text, just set the imageView.image property of the cell to a corresponding image. If you want a different layout, however, you will need to create your own custom UITableViewCell, which is not a hard task at all. Here is a tutorial on how to create a custom cell using IB. It can also be done programmatically if you prefer to do it that way. I hope this helps to solve your problem.

Good ways to dynamically generate the start image of an iPhone/iPad app

I'm self-learning iPhone development and I see that one of the aspects of an iPhone/iPad app is the start image that gets displayed when your app is run. I'd like my start image to display some basic info about the user when the app is launched, but that info has to first be collected by the user when the app is first run. That tells me that I either need to dynamically generate the start image after the user enters their information or I need to place a label of some sort on top of my static start image in order to accomplish this. The first time the app launched and before the user enters their info, the start image can be anything or nothing at all, I'm not concerned about this.
So, my questions are...
Can you place controls, like a label, on top of the start image when your app is launched?
If not, what's a good approach to dynamically generating the start image after the app is launched for the first time and the user info is collected?
If there's no way to change this start image (thanks kristopher!), can I instead display my dynamically generated image for a set amount of time (~3 seconds) as soon as the start image closes? Do I even have to use a start image at all?
Thanks so much in advance for your help! I'm going to begin researching this question right now.
To answer number 3, Yes, you need a start image. It should look like your dynamic start image but without the dynamic information.
To display the dynamic information briefly after launch, just use a modal view controller on top of whatever view controller comes up first (called viewController below):
SplashScreenController *splashScreen = [[SplashScreenController alloc] initWithNibName:#"SplashScreenController" bundle:nil];
[viewController presentModalViewController splashScreenController animated:NO];
[splashScreenController release];
[viewController performSelector:#selector(dismissModalViewControllerAnimated:) withObject:YES afterDelay:3];
Obviously you need to create a UIViewController subclass and xib file called SplashScreenController.
Apps can't change their start images. Those image files, as well as other files in the app's bundle, are treated as read-only by the OS.
If you don't have a startup image, then the user will just see a black screen for a second or two (or more, depending on how big your app is). It's a good idea to have a startup image.
You can display whatever you want after your app starts running.
I do something similar to what you are trying to accomplish, except I do not display user information. If you want to see what I did, check out my app How Long Can You Tap It (free). The Very first image, as Kristopher mentioned, is not changeable. It will be displayed for as long as the application takes to load. Then, the image will disappear and show your initial viewController, which will be whatever you want. In my app, it simply is the same image is the initial image, but instead of saying LOADING I display text telling you to Tap the screen to start playing. If you don't want to rely on the user to tap the screen to continue, you can do what Frank said and dismiss it within X number of seconds. If you want more code than what Frank provided, let us know.

Image Caching Problem in iPhone

I have briefly described the working of my application to under stand my Question.
I have an application, in which more than 1600 images are stored with in iPhone-Application-Document Directory.
I have a tableView on Main Screen as follows.
=>First Category
=>Second Category
=>Third Category
=>if user selects First category, Images are loaded in my ScrollView
Like
|--------------------Page View Controller-----------------|
| First Image | Second Image | Third Image | Fourth Image |
|--------------------Page View Controller-----------------|
After selecting Category, User can see - First Image From Page view Controller & others are already loaded in page View Control, user has to just scroll left - right to see the other images, but at a time user can see only one image.(that is the task of page view control)
Now Each Page has an Image View Placed in Scroll View (so user can zoom in out)
All this things work Perfectly,
Problem occurs in following situation.
=>After watching first category's images
=>User presses Back
=>Now user selects second category to view all images of second category are loaded in page view controll.
iPhone terminates the application in the given situation. (as it can't load all images to page view control)
(each image is of at-least 4 MB approximately.)
iPhone simulator works perfectly in described situation but iPhone doesn't.
iPhone terminates the application in given situation.
I think there might be memory caching problem in iPhone.
Question is how to resolve this problem?
Thanks in advance for helping me.
You are having a memory problem, you need to manage your pictures better, release them from memory when not in use. For your scroll view dont load all images at once, load at most three, this is all you need, the reason i say three is because youll have something like this
PIC ActivePic Pic
or
ActivePic Pic - here you only need 2
You load picture on each side of the active picture so when the user scrolls clipping does not occur. When you are not in the scroll view make sure to release all the images if not ull run out of memory like you have been expiriencing. Look at the sample project PageControl here http://developer.apple.com/iphone/library/samplecode/PageControl/, here they manage t he views of the scroll view in the same fashion described above.

Generate View for iPhone application using interface builder.?

I wanted to generate one fix view using interface builder, but the size of that view is exceeding the size of iphone screen,and I am not able to maximize screen. I wanted to show table view in that screen.
I did enabled scrolling but that didn't work,
Update 1:
Actually I wanted to show thumbnail image inside cell and i want to show 5 cell so 5 thumbnail image,those images are static. So which is a better way to achieve this ,interface builder or programming?
Hope this is clear enough.
Your question is not terribly clear, so this is the question that I am attempting to answer here:
You want to have a table view which has five rows, each of which has a small image.
Short answer: you can't do this entirely in the Interface Builder. What you can do is define your table view, including the "look," scrolling abilities, etc. And then in the same XIB file you would define the table cells (which can include your pictures, captions and what have you).
You then have to connect the two together programatically. Apple provide plenty of examples in the SDK on how to do this.