NSArray to display photos inside a UIImageView - uiimageview

I need a little help. I am new to programming and I am trying to create an app that shows photos, like they were a magazine.
I can say I am on the half path.
I am trying to create a NSArray with the name of the photos, so I can display them in a UIImageView.
But, how can I send this message to the UIImageView when the information comes from the NSArray?
Actually, let me explain it more. The user will be able to swipe between the photos. The effect is gonna be the curl one, like iBooks.
The problem is that I do not know how to change the UIImageView to display the photos.
Can I create a viewcontroller to each photo and then add the UIViewAnimationTransitionCurlDown to change between them? What's the easiest option?
Well, hope you guys can help me.
Thanks!

You should look into UIPageViewController. Essentially, you would have a main view controller that contains the array of photos. This would have a child view controller that is a page view controller. The page view controller would refer back to the main view controller for view controllers to display, and the main view controller would provide it with view controllers that contain image views initialized however the main view controller wants it. Take a look at Apple's tutorial, as well as this tutorial, for more information.
Hope this helps!

Related

iOS 8 Share Extension custom view controller size

I'm building a share extension for my iOS app and I can't use the default SLComposeServiceViewController, so I created (in the storyboard) a basic UIViewController and embedded in a navigation controller. I get to present it, dismiss it etc but it's always full screen. I would like to make it look more like a dialog.
I have tried using self.preferredContentSize on my view controller, tried Use Preferred Explicit Size on the navigation controller in Interface Builder, but it doesn't work.
This can be done easily and directly using the storyboard but is not immediately obvious. There is no need for multiple view controllers.
Create your own view controller class inheriting from UIViewController.
In the MainInterface.storyboard change the class of the view controller to your new class
In the storyboard you can simply draw your UI - but here is the trick. You need to understand that the storyboard view will fill the screen and by default the view has already been created with a clear background. You simply need to create a view inside of the main view. You can set auto layout constraints to size this view and position it (e.g. centered horizontally and vertically). You can also use size classes to cause this inner view to fill the screen on compact layouts. Connect the controls from the inner view to your view controller in the usual way by control-dragging
In you custom view controller you can refer to self.extensionContext to read and complete the share action. Refer to the code in the template ShareViewExtension
Ok I spent a long time trying to figure this out. For whatever reason you can't set the view size like you can with the action extension. It will always go full screen (even on iPad). So a way around this is to make multiple view controllers. Make the first view controller hidden so the user doesn't notice that there is a full screen view controller present (And yes, in a share extension the first hidden view controller actually hides completely so the user doesn't even know it was presented). Then present your actual view controller using the hidden view controller. This way you can present it any way you like and set the size etc.
In my case I actually made my hidden view controller have a UIEffectView so I can have a nice blur animation in the background and then present my actual view controller over it.
Here is a picture:

xcode segue jump management in a app with many views

I have seven views that I need to navigate between from any of the other views. I don't want to keep doing segues from each one as new instances would keep being created...among other issues. What I was originally trying to do was have all the segues start from a home view and then go to the designated target view. When the user left that target view a public variable would be set if they wanted to go to any other view other than the home view. When the home view reappeared, it would check that public variable to see if another jump was needed. In the Home view I put the segue jump check in the -(void)viewDidAppear:(BOOL)animated function. The problem with this being you see the home screen for a second before it goes off to the new target view. The -(void)viewWillAppear:(BOOL)animated does not work for segues. I guess this is because it hasn't fully released the old segue yet?
Is there a better way to handle a freeform many view navigation issue like this? If anyone needs it, I can post some sample code for what I was trying to do. Thanks in advance for any help.
It sounds like you need a UITabBarController.
It allows you to have multiple view controllers, and switch between them by tapping the tab on the bottom of the screen.
It allows you to have only one instance of each controller, so that as you switch between them, data persists and you aren't creating new instances each time.
Here is an example of what one looks like (notice the tabs at the bottom of the screen):
(source: xamarin.com)

Using a table to add objects/images to a view

First off this is Xcode 4 iOS 5.0. Here is what I want to do. I have one view, we will call it view1, which has a button and when that button is pressed a different view with a table appears called tableView. I have multiple images I want to be in this table and when the image is selected, it would appear in view1. I have already researched all of this and just can not find the right material. The button and table are already working together and I can add the objects to the table, but getting those objects that I select to appear on view1 is what I am not understanding. I can not get the two nib files to work together, or Im going at it wrong.
Second question, guess this is similar, view1 displays an image that is selected from the photo library BUT is there a way to open the photo library, select the photo, and have it appear in a DIFFERENT nib view? Again this is getting the NIBs to work together. I would appreciate all the help I can get. (photo library and selection of photo already works so that code is not needed). Thank you for the help!
I have used this example to get what you have described in the above question. But with some tweak in the delegate methods and hop you will get some direction for your problems, too.
Good Luck!
Happy Codding! :)
And need any help just ask for it, don't hesitate.
It is possible from delegates in other class.

How to set size of UITableView inside Interface Builder?

Is it possible to change the frame of UITableViewController's UITableView frame inside Interface Builder? I want to make my table, which I instantiate in IB, a little bit narrower.
When you have create your tableViewController in IB, if you then go to the section on the right of the screen where all the options are set size to "freeform" then drag it to whatever you like. When you init it it will then get this frame. Unless it is within a container controller.
The best way to do what you are after is to create a viewController and add a table view to its view. Make the table view narrower that the main controller view and wire it up to an IBOutlet on your controller. If you then make your controller implement the and methods you will be able to use your table view exactly as you want to.
Hope this is of help to you, if this is unclear or you would like any extra help, let me know :)
You can change it in IB but unless you customize your view controller somehow, it will set it be full screen (module enclosing controllers like nav, tab bar, split view, etc.) That's just the way view controllers work.
From the Apple docs:
When a view controller is displayed on screen, its root view is
typically resized to fit the available space, which can vary depending
on the window’s current orientation and the presence of other
interface elements such as the status bar.
You can create another UIView to hold your table view and then have more control over the table view sizing, But then you won't be a table view controller and will have to implement some of the things that table view controller provides you, e.g., deselectRowAtIndexPath on viewDidAppear.

Switching from a UITableview controller to a viewcontroller

I'm just learning and playing with the apple Seismic XML example
http://developer.apple.com/library/ios/#samplecode/SeismicXML/Introduction/Intro.html
I've got most of it figured out, but the one area I can't get past is, if I want to remove the tableview controller and create a view controller populated with a tableview. I can get the tableview to appear fine, but no matter what I try I can never get it to populate.
In the viewdidload area I can setup the tableview, color the background, do whatever I want to do, but I seem to 'lose' control of it somehow.
In short, would someone please be able to give me the steps involved in correctly changing the tableviewcontroller to a viewcontroller with a tableview in the apple example?
Thank you.
Lian, you need to read the documentation on UITableViewController. http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/AboutTableViewsiPhone/AboutTableViewsiPhone.html
I'm not sure what you mean by "remove the tableview controller and create a view controller populated with a tableview" or why you would want this configuration. If you're having trouble with populating the tableViewController, you just pass in the data, usually from an NSArray or NSDictionary in the cellForRowAtIndexPath method. You either need to select the UITableViewController template when you create the class file or include the UITableViewDataSource and UITableViewDelegate if you're adding a tableView to a ViewController.
If you mean you want to change the view controller on screen, then you're looking to pop to another view using the navigation controller.

Resources