Flipping between two UIView inside UIScrollView - iphone

I have a scrollview with lots of subviews, my problem is when i tap one of the subviews i want to change it to some other view that i would create in that moment.
Imagine this case: having a picture gallery and when you tap on one pic it would show the backside of the photo (having some kind of info about it).
At the moment, i know which one i've taped onto and fliping it is also OK, but setting this new UIView in its place with the flipping animation... i'm not getting it!
Thx in advance for your time.
EDIT:
[UIView transitionFromView:recognizer.view toView:flyerInfoView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromRight completion:nil];
[UIView commitAnimations];
I've made this, but i'm having 2 problems, i can't back to my other view (as i've read in the documentation this method removes the "fromView" from the superscreen) and the other one is... It is fliping all my views not the only one i'm touching.
You can see that fromView is recognizer.view, i'll briefly explain, i have a UIGestureRecognizer assign to each view so i can understand which view is being touched. The method that is fliping the view is: handleTapFrom:(UIGestureRecognizer*)recognizer
how this can give you a more detailed info about my problem.
Again thx a lot for your help.

Have you already tried to use UIView's method transitionFromView:toView:...? There are some Flip options too.

Related

iOS Scrolling Interface - FoodSpotting signup interface

I'm not sure if you guys have checked out the sign-in/sign-up interface for the iPhone app "FoodSpotting
, but it's pretty cool. Somehow they're able to move what seems to be a UITableView vertically downwards to create an entirely new view with a slick animation. It essentially looks like they're moving the entire screen down, but yet when you try and scroll back up to the original sign-in screen you can't.
Does anybody know how to get this kind of functionality with either a UITableView, ScrollView, or regular UIView? If you need more clarification on the kind of animation I'm talking about either download the app or I can try and post pictures...
Hey I actually built that page! It's pretty simple: It's just two UITableViews, and a simple Core Animation animation is used to "scroll" between the two. I suppose a similar effect can be achieved using only one tableview, although using two separate ones allows us to take advantage of the individual tableview's scrolling behavior to do things like move the form up when the keyboard appears.
EDIT:
I know this is SUUUPER late, but here's a quick explanation...
My controller is a UIViewController subclass, not a UITableViewController. In the viewcontroller's view, I set up two tableviews like this...
Black = Status Bar
Red = Screen Area
Blue = Top TableView
Green = Bottom TableView, positioned just offscreen
The code to transition between the two is pretty simple...
//transition to bottom tableview
[UIView animateWithDuration:ANIMATION_TIME animations:^{
bottomTableView.transform = CGAffineTransformMakeTranslation(0, -self.view.frame.size.height);
topTableView.transform = CGAffineTransformMakeTranslation(0, -self.view.frame.size.height);
}];
…
//and to return to original state…
[UIView animateWithDuration:ANIMATION_TIME animations:^{
bottomTableView.transform = CGAffineTransformIdentity;
topTableView.transform = CGAffineTransformIdentity;
}];
Yes you are right. It's a UIScrollView on UIView. By default scrollview is scrollable and on completing sign up View is animated.
So this will be easy to implement.

Flip animation between two UIViews on a UIViewController

I have two UIViews on my view controller. I wanted to flip between the two views on user touch. Everything is fine except the animation I tried two methods, first was:
[UIView transitionFromView:frontView toView:backView
duration:01.0 options:UIViewAnimationOptionTransitionFlipFromRight
completion:NULL];
This was animating the view but actually animating the whole view controller's view, while I wanted only the portion where my views are, which is about 320x200 in the centre of the screen.
Then I tried the other option, which is:
[UIView animateWithDuration:1.0 delay:0.0
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[frontView removeFromSuperview];
[self.view addSubview:backView];
} completion:nil];
But this is not animating the views at all. Just switching the views instantly without any animation. Can anyone please help me in understanding where I am wrong or need to change. Thanks very much for your time and consideration.
Awhile after I posted my question I found a great answer for this query which you guys can look at :
How to flip an individual UIView (without flipping the parent view)
The trick is to use third UIView as container view and then adding the views, which needs to be animated, as subviews on it. That does the trick in my case. Remember that I am using the first method that I mentioned in my question. Thanks everyone for your time.

Howto make iPhone screens sliding out? (Animation)

in some iPhone/iPad Apps you can see screens sliding in and out.
How does the straight slide in/out work?
I could only find Curl and Flip for animation:
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
not sure what you mean by sliding in and out, perhaps provide an example app with it
I think you mean pushing a view to the left to reveal the next view under it or something similar
-(void) slideView:(UIView *)uiv_slide toReveal:(UIView *)uiv_reveal withDuration:(double)d_duration {
//Add the subview to the ViewController's view
[self.view addSubview:uiv_reveal];
//Bring the view to slide to the front
[self.view bringSubviewToFront:uiv_slide];
//Make an animation to slide the view off the screen
[UIView animateWithDuration:d_duration
animations:^ {
uiv_slide.center = CGPointMake(-1*(uiv_slide.frame.size.width/2), uiv_slide.frame.size.height/2);
}
];
}
hopefully the code helps
If you make your app based on the navigation app template, the transitions for going from view to view will have that slide in/out animation.
Take a look at some custom animations here. This will allow you to animate your views however you want. You can also use the apple navigation controller to build a drill down structure to your apps. Those view will automatically slide transition.

How can I use UIModalTransitionStylePartialCurl on a UIView that does NOT take up the whole screen?

In Apple's official Maps app for the iPhone, there is a small 'page curl' button in the lower-right corner. When you press it, the map itself peels back to reveal some options. I would like to duplicate this effect in my own app.
I'm trying to use UIModalTransitionStylePartialCurl (Added in SDK 3.2). In terms of its layout, my app resembles Apple's official Maps app almost exactly. I can easily get the ENTIRE screen to peel back, revealing another view underneath, but I don't want this. I want ONLY the map view to peel back.
In order to create this effect, you must have a UIViewController that will perform the transition. If I set this UIViewController's view to a small subview somewhere on the screen that does not take up the entire screen, I can get just that subview to peel back. That's great! However, after the second part of the transition (when the page falls back into place), the views are never where they started. Either the view that peeled back will have moved from its original position, or the view that was revealed will have expanded to take up the entire screen.
Is there any obvious mistake that I'm making? I would really appreciate any help!
The code I'm using is really simple. It's basically just:
underMapViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[curlableMapViewController presentModalViewController:underMapViewController animated:YES];
From the Documentation:
UIModalTransitionStylePartialCurl
When the view controller is presented, one corner of the current view curls up to reveal the modal view underneath. On dismissal, the curled up page unfurls itself back on top of the modal view. A modal view presented using this transition is itself prevented from presenting any additional modal views.
This transition style is supported only if the parent view controller is presenting a full-screen view and you use the UIModalPresentationFullScreen modal presentation style. Attempting to use a different form factor for the parent view or a different presentation style triggers an exception.
Although, I haven't got any exception using other presentations than full screen. I was testing out and I get the same problem as you. I found that if my ParentViewController's view is an ImageView and I set the content mode to UIViewContentModeCenter, the view is not resized or moved. Maybe there is a workaround by saving your current view as an image, put it at the top, make the curl, and after you dismiss your modal, rearrange the messed hidden stuff and remove the top image view. I know that it sounds crazy but that is what I would try if I really had to accomplish that requirement.
Hope this helps, Jorge.
How about something like this:
[UIView beginAnimations:#"PartialPageCurlEffect" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myOldSubViewController.view cache:YES];
[myOldSubViewController.view addSubview:myNewViewController.view];
[UIView commitAnimations];
Note: for some views if the views are complex and off-centre there could be artifacts. Changing cache:YES to cache:NO may fix with.
As cprcrack points out, this doesn't answer the original question. However, it's useful information, so with that in mind I'm going to leave it here.
This is actually much simpler than you'd guess.
We'll call the view controllers MapViewController and SettingsViewController. Your problem is you want to peel back part (and only part) of MapViewController to show SettingsViewController.
Here's how you do it:
Use a full size view for both views.
Only put content on the bottom half of SettingsViewController's view.
Use UIModalTransitionStylePartialCurl to transition between them, like you already are.
iOS will detect that you've done this automatically and only peel MapViewController's view back far enough to the bottom half of SettingsViewController's view, which is where all your content is.
If you put content in the top half of SettingsViewController's view, iOS will detect that and peel back MapViewControllers view all the way instead.
Summary: Put content only in the bottom half of your new view. iOS will figure it out.
(I don't think this is documented anywhere, sorry.)
I had a slight hiccough confusing
.modalTransitionStyle
and
.modalPresentationStyle
The first one goes on the TARGET viewController, e.g., the one you want underneath. The second goes on the PARENT viewController, e.g. the one that actually gets distorted by the curl. The OP got this right, but I got it wrong, and it was a frustrating 10 minutes before I figured it out. Throwing it on this post in case it gives someone else the head slap I needed.
I ran into this problem as well. For me the frame of the parent view wasn't mangled until the modal view was dismissed. So I cached the frame before dismissing then restored it right after.
CGRect frame = controllerWithModal.view.frame;
[controllerWithModal dismissModalViewControllerAnimated:YES];
controllerWithModal.view.frame = frame;
Me too had this problem,but i solved it..(dont know its the right way,but its working)
I wanted to had an imageview inside a scrollview,and when the user taps a button inside that scroll view i wanted to curl-up the scroll view and show a tableview in that place.
So i placed a tableview behind scrollview and initialy set it to hidden.when the user taps button
i did
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:frontView cache:YES];
[UIView commitAnimations];
after that removed frontview from view.
Hope that helps..
I believe that Apple's Maps application uses undocumented transitions: mapCurl and mapUncurl. I am not sure there is any way to do exactly what caecus314 wants (which is also the effect I have been trying to duplicate).
UIModalTransitionStylePartialCurl will curl up the whole bottom part of the first view, including the toolbar, which is unlike Apple's Maps app, which only curls up the map and leaves the toolbar in place.
As far as I can tell there is no way to only curl up the map.
Override the viewWillDisappear method of your underMapViewController with something like this:
- (void)viewWillDisappear:(BOOL)animated
{
curlableMapViewController.view.frame = CGRectMake(0.f, 0.f, 320.f, 416.f);
[super viewWillDisappear:animated];
}
That corrects the size of the view of the curlableMapViewController to the know size you specify, which you could save earlier in the viewWillAppear method, for example.

UIView Subview Does not autoresize on orientation change

In my iPhone app, I have a view controller with two views (essentially, a front & back view). The front view is the main UIView, and the back view is a secondary UIView which is added as a subview using [self.view addSubview:backView] when showing the back and [backView removeFromSuperview] when hiding it. However, when the orientation changes, I have the following issue: the main UIView (frontView) rotates & all of its elements resize properly, but the secondary/subview UIView (backView) does not rotate & all of its elements do not resize properly. Does anyone have suggestions on how to make the secondary UIView autoresize properly according to the rules I have set in Interface Builder?
In the end, the solution I found was simply to separate my UIViews into separate UIViewControllers, and make sure that any views that I wanted to be able to rotate only had one UIView.
If I understand correctly, at the time of rotation 'backView' has been removed from it's superview, yeah? If so, that's the cause of the problem. The autoresize property determines how the view resizes relative to it's superview. If it doesn't have a superview it won't resize.
Perhaps using [backView setHidden:YES] instead of [backView removeFromSuperview] will be sufficient for your needs.
I had the same problem, here is how I fixed it based on imaginaryboy's
suggestions (thanks!)
Add the backview to the viewcontroller at viewDidLoad and hide it at the same time. Show it when needed, Hide it again. Set the resizing of the backview to UIViewAutoresizingFlexibleWidth in IB (or code I guess, I used IB)
Not that this is the same problem, but I found a similar problem when adding 2 subviews in my application:didFinishLaunchingWithOptions method. Since your reference above is using [self.view addSubview:view], I would understand that to mean that self is not your UIWindow. When adding an additional view controller to your App Delegate window (UIWindow), the second view controller will NOT receive any rotation events and will never rotate. Only the first view controller added to UIWindow will rotate. See:Technical Q&A QA1688 I believe this also affects views added after the first view where the first view is later removed from the superview.
I ended up following the suggestion I read elsewhere to use separate views for each orientation, thereby eliminating the need to worry about resizing behavior. As always, YMMV.
Or; if you want to avoid an additional controller, you can achieve the same effect by setting view.frame in willRotateToInterfaceOrientation:: like so
if(UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) ;//set stubborn view.frame for landscape orientation
else ; //set stubborn view.frame for portrait orientation
Although it feels like a hack; it's simple.