Create a swipe feature within an UIImageView - ios

In my current test app I have a UITabBarController, linked to a UINavigationController that leads to a UIViewController with 6 buttons in it and a second UIViewController with a UIImageView. I've created a segue for each button, wich works.
I want to be able to create a swipe pictures feature inside that UIImageView. The source pictures are inside the app's folder.

I'm not sure about your question.
If you need to create a sort of slider of images, you could create a UIViewController with a UIScrollViewas the main view (or as a subview of UIViewController's view).
Once set up, you could create a for-loop where you create UIImageView elements to wrap the image you are loading from your app folder and add each UIImageView to the scroll view.
To make possible to snap photos within the UIScrollView set its property pagingEnabled to YES.
For further info you could take a look at Scrolling sample provided by Apple.
Hope this helps.

Related

When to use UIViewController vs UIView when animating?

When should a UIView be placed over the current views (in the same controller) vs adding a whole new UIViewController?
I know that the UIViewController manages UIViews, but imagine that you wanted something to popup when a user selected something. What decides whether a UIView be animated and added to the current controller (using animateWithDuration), or a new UIViewController with a custom transition?
Twitter example:
http://i.giphy.com/3o7TKKcmcIz76ONXFe.gif - Not sure if this is a UIView added to the existing controller, or if it's a new controller. I just tap the image, and it pops up. I then slide down and slowly move the image off the screen (interactively).
Spotify examples:
http://i.giphy.com/3oz8xRSkmxbcVqPZf2.gif - Probably a UIViewController. I'm grabbing the bottom bar and sliding it up. I then slide down on the album cover.
http://i.giphy.com/3oriO7SjzB5GfThx60.gif - Possibly a UIView? Happens when I press and hold a album cover.
What determines when one should be used over the other? It would probably be helpful if you explained the examples. Thanks.

Swift: How to arrange UIViews inside UIViewControllers?

Real simple (and I've reviewed articles for 30 minutes with no match), I have a UIViewController in a swift storyboard.
I needed to add a background image to the screen, so I added a UIImageView, set my background image, worked great.
I also added a UIView called ButtonsView "above" (meaning below in the storyboard editor) the UIImageView so that when I programmatically add images to the UIViewController so they appear over the background.
Now I need to my code that previously used the addSubview to the main VC.view to add to the newly created VC.view.ButtonsView in the storyboard.
I can't seem to get the compiler to see my UIView ButtonsView regardless of what identifier or accessibility I use in the editor. I also can't find any documentation on this specific process.
How doe one programmatically reference a UIView inside a UIView inside a UIViewController?
I'm 100% storyboard for all the above.
You are describing an outlet. Give CategoryViewController an #IBOutlet property (let's call it buttonView) that is an Optional UIImageView, and hook it in the storyboard to the actual ButtonView.

How to create a separate view in Storyboard to be included programmatically in UITableView?

I have a UIViewController with a UITableView that is fed with data from the local database. When the user first launches the app (after installing) the table view is empty and I display a UIView in the middle of the table view that contains a UIImage, a UILabel and a UIButton (a call to action).
The first version of this view I built programmatically, which was no good to me because every time I tweaked something I had to build the app again. Then I switched to the storyboard but had to drag a UIView to the middle of my tableView. It is working now but I don't like the way it is, I can't edit my table view cells without having to move the UIView out of the table view.
I'd like to have a way to build this view entirely separated from my tableView (or even from my view controller in question) and then reference it in the viewDidLoad call of my view controller.
Unfortunately Xcode does not allow us to drag views directly to the storyboard so I'm pretty lost here.
Please tell me if I haven't been clear enough. I appreciate any help you could give me.
UPDATE: It'd be particularly awesome to me if I could also create a custom Swift class for this view of mine and reference it in the storyboard. And then in my viewDidLoad I could simply instantiate my custom view.
Thanks in advance.
Create a XIB file in which you can drag a view (without a view controller).
In your code you can load the XIB using NSBundle.mainBundle().loadNibNamed("MyXibName", owner:self, options:nil).
In the XIB file you can give the UIView a custom class (like you can do with view controllers in storyboard).
You then of course have to retrieve the view from the array returned by loadNibNamed and cast it to your custom class.

UIButton inside a UIScrollView

I would like to use a scroll view inside my app.I will explain the situation:
Mine is a recipe app.I would like to show all the recipe images inside a scroll view and when i click an image inside the scroll view ,the corresponding ingredients and preparations has to be shown .I saw many tutorials using image view inside the uiscrollview,thought of replacing image view with button.But all those tutorials are so complicated .Can any one refer me a simple example.
This my apps seccond page.when i click a particular recipe in first page its image and ingredients and preparation is shown.But i would like to show all the images in uiscrollview,and when i click a particular image,corresponding ingredients and preparations has to be shown
From my point of view I think that if you would use a UITableView or a UICollectionView (or the corespondent controllers: UITableViewController and UICollectionViewController) you would achieve grater results than trying to add buttons with images inside a scroll view.
UITableView Tutorial and UICollectionView Tutorial
Also you can go and watch the Apple's WWDC videos
I hope this is helpful for you,
Cheeers
Place UIscrollview In View Xib, then add UIButtons Inside UIScrollview , set buttons actions by hooking action type touch up inside in button pressed add subview on UIView and Show details of Recipe.[self.view addSubView:RecipeDetailView]; here recipe detail view subview where you load reciepe info on button pressed.

Multiple UIView in one UIViewController

I am developing a iPad App.
There is one UIViewController which should show all relevant information.
Inside this VC there are 2 UIViews: The first UIView on the first half of the Screen shows a Image and some text. The second View on the bottom half of the screen should display some stuff like a map or a image gallery depending on the button that was pressed in the center of the screen.
My first try was to load for example a GalleyViewController and then get his View and add this as a Subview to my BottonView like this:
-(void)galleryButtonPressedInCenter{
GalleryViewController * gal = [[GalleryViewController alloc] initWithNibName:#"GalleryViewController" bundle:nil];
[gal.view setFrame:CGRectMake(0,0,620,300)];
[self.bottomView addSubview: gal.view];
But this will crash my app if I touch the View with my finger.
To show what I want to achieve:
On the last Screenshot (http://itunes.apple.com/de/app/ebookers-hotels-furs-ipad/id465464927?mt=8) you can see that in this App there is a ImageView and some other Stuff in the upper part and in the lower part there are multiple Views that are switched depending on the button that was pressed.
Make an empty fullscreen view.
then add your subviews to that view.
ViewController
-UIView (your new umbrella view)
-UIView (subView 1)
-UIView (subview 2)
I don't think I've seen it documented in the helpfiles, but I'm finding that each "ViewController" can only have one UIView directly attached. I'm kinda new at this though, try it anyway :)

Resources