I'm fairly new to iPhone programming, and I'm making a fairly basic app. Anyway, I just want to know how to go about creating a menu that scrolls up from the bottom (beginning at the top of the tab bar) that displays a few options. I've attached a picture that better helps portray what I mean. I'm assuming I should create some sort of subview and then add some animation to it, but I'd like to get your advice on the best way to start.
Thanks
The simplest solution would be to use a UIActionSheet, unmodified.
If that's not what you're looking for, using a modal view controller is always an option.
If, however, you want something that won't cover the entire screen, and can have a custom look, the basic idea is this:
Create your view with a frame that's just at the bottom of your main view (e.g. at 0,406).
Optionally disable user interaction with the main view
Use UIView animations to move it up
The code would look something like this:
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, kCustomViewHeight)];
[self.view addSubview:customView];
[UIView animateWithDuration:0.2 animations:^{
CGRect f = customView.frame;
f.origin.y -= kCustomViewHeight;
customView.frame = f;
}];
I didn't do it myself, but saw a cool source-code, where it was performed with the helped of UIScrollView (by default positioned "below" the screen), containing UITableView and a button (wich was shown at the bottom of the screen). ScrollView was getting a command to move after the press of this button (in IBAction of it).
Being shorter, try to look at UIScrollView (play with UITableView in it).
I've done something similar, popping up some object from the bottom of the screen by subclassing UIActionSheet and adding my own controls as subviews. I imagine a similar method could be used in your situation.
Create a subclass of UIActionSheet implementing the UITableViewDelegate and UITableViewDataSource protocols. In the - (id)init method of that class, add a UITableView as a subview with self as the delegate and data source.
Then from the main view, call your custom UIActionSheet with showInView:.
Use delegates to call back to the main view to let it know when the user selects an option, then use [myCustomMenu dismissWithClickedButtonIndex:0 animated:YES] to hide the menu.
Related
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.
I'm trying to make a modal view and a non modal view appear the same.
The modal view is a library I'm using.
I want to use the same transitional effect on both, is there one I can use ?
No for ModalView Controller you have your standard Animate: YES, and NO, this just shifts it up, or DOWN (if you dismiss Modal View contreoller)
my technique is building UIView's into the same xib/nib and using the 6 animations that are offered on that for a really cool effect. in the end you can tie the UIVIew up in another new class (NewView), and add that class object to your xib and tie up the buttons etc...
header...
#interface NewView : UIView {
IBOutlet UIView *mynewView;
}
#end
implmentation... for say a button)
-(IBAction)openThisPage{
[UIView beginAnimations:nil context: NULL];// Setting up the Animation
[UIView setAnimationDuration:1.0]; // Duraction
[UIView setAnimationTransistion:110 forView:self cache: YES]; // Type of Animation
[otherUIVIEW removeFromSuperview]; // removes UIView to Screen
[self addSubView:otherUIView]; // adds a UIView to screen
[UIView commitAnimations]; //creates the animation
}
other naimations as you can see i said 110 for one of those animations,
110 = bubble effect animation
UIViewAnimationTransistionFlipfromLeft = Flip from Left Side, change Left ot Right for right side
UIViewAnimationTransistionCurlDown = Curls the page from Top to Bottom, put Up for opposite effect
103 = Genie Effect
also their is a couple more using the camera roll, but no user's use that unless they are leaving or entering the camera roll, I have not touched them myself....
what do you mean a library you are using, like a Core Data UITableView ?
building it with UIViews I have noticed is always alot easier, easier for manipulation with on screen effects, creating simple drill down file menu's
so basically create a new class, with no XIB, name it hwatever, change the class implementation delegate to UIView, add a view to that new class
go into your main XIB, add a Object, change it's properties to that new class, and then tie up new buttons and create a UIView in that XIB and tie it to that class, and you are good to go :-)
I could post code, but I dont really have a solid example on this computer... let me know if this helps....
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.
I have a UIViewController containing its UIView which occupies the available screen (inbetween the tabbar and nav bar).
I'd now like to add a simple toolbar which is situated at the top of the UIView which will contain some buttons. One of the buttons should display a drop down menu which is displayed as an overlay over the UIView. I'd quite like this menu to be a UITable as it could contain many items.
The problem I'm having is I can't see the best way to go about this. I'm wondering whether there's a simple strategy.
Here's an example of the type of feature I'm looking for...
Menu hidden: http://www.flickr.com/photos/peterevers/3147678219/in/photostream/
Menu displayed: http://www.flickr.com/photos/peterevers/3148550320/
I expect the above example is emulated in UIWebView using HTML/CSS. Is there a "proper" way?
TIA
I create a UIView, actually I create a new Status Bar, custom Color, graphics, and a clock on it, the menu UIButton has this function called, but make sure also in your H to add the button and the UIView and attach it to the newly created UIView in IB.... IBOutlet UIView *nameofMenuUIView;
[self addSubview:nameofMenuUIView];
or you could do
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransistion:READBELOW forView:self cache:YES];
[self addSubview:nameofMenuUIView];
[UIView commitAnimations];
READ BELOW: this READBELOW text above can be changed to 103 104 110 or even page curl up/down etc.... look for Animating UIView's their is about 6 animations you can use, however 3 of them are dedicated to the camera roll, so pointless for a menu...
You could certainly use the buttons that you want in your menu to show and hide a UITableView. There is no need for a WebView, I think you are already on the right track.
There's no built-in support for this. It seems straightforward to implement - make sure the table view is beneath the header, then move it and the content view down when you want to show it. Was there a particular part you were stuck with?
Another option is to use a third-party library such as HGKOptionPanel or WEPopover.
I need to customize the page where on any event the customizable "Button menu pane" has been visible from the bottom, just like one of the application "Twitterrific" (please see the screenshot). I've tried to implement through with modalViewController properties but it populate my customizable view on the whole screen and my parent view is disappeared in the background.
Code snippet:
MyCustomizableButtonMenuContoller *buttonMenucontroller =
[[MyCustomizableButtonMenuContoller alloc] init];
// To show my customizable button menu from bottom at parent view on any event.
[self presentModalViewController:buttonMenucontroller animated:YES];
//To hide customizable button menu.
[self dismissModalViewConrollerAnimated:YES];
I've also tried to transparent my customizable button menu view but it doesn't work on my requirement. The UIActionsheet seems to be the one i'm looking for but again is it possible to customize the buttons with images? If there are any other ways to achieve the scenario in the screen shot, please let me know about your findings or ideas.
Screenshot:
Twitterrific screenshot http://scaline3.appspot.com/Button_menu_pane.png
You don't want to use a modal view controller for this. You can't achieve this "partial overlay" effect that way, because the iPhone OS makes several assumptions about the views of nested view controllers.
Instead, you need to create a UIView with several UIButtons inside that is initially hidden off the bottom of your primary view. When the user clicks the customize button, you need to animate the view upwards into place. The panel will be part of your main controller, but your code shouldn't be too much different.
If you're just getting started with Objective-C, you should read the Core Animation documentation. You should be able to animate the view into place with very, very little code. Here's an example:
[UIView beginAnimations:nil context: nil];
[UIView setAnimationDuration: 0.5];
[myDetailPane setFrame:CGRectMake(0, [self bounds].size.height - [myDetailPane bounds].size.height, [myDetailPane bounds].size.width, [myDetailPane bounds].size.height)];
[UIView commitAnimations];
No timers or gradual movement of the view is necessary - the system will take care of it.
Apple's example in their documentation seems to make use of Navigation Controllers. This might give you some help: Using Modal View Controllers
Good luck!