Application Design - Menu system - iphone

I have a UIViewcontroller that has a UITableView and and a couple of buttons, (add and done)
When the user clicks add I need to get some details (which represent a notification they are setting in the app).
Details like notification name, a number, target score etc...
What is the best way to get this info, is it a good idea to use a UIView and animate it onto the screen with some textfields or something like that?
Any good cocoa controls you can recommend?
Problem is my app already transitions from the rootview controller to the notification input controller modally, I was trying to get a simple UI to just enter data, I could use UIAlertViews but they are so ugly....

based on your comment above:
CustomUIView *inputView = [UIView alloc]initWithFrame:CGRectMake(offscreenRect)];
inputView.alpha = 0;
self.notificationInputController.userInactionEnabled = NO;
[UIView animateWithDuration:.5
animations:^{
inputView.alpha = 1;
inputView.rect = CGRectMake(onScreenRect);
}
completion:^(BOOL finished) {
[self.notificationInputController addSubView:inputView];
self.notificationInputController.userInactionEnabled = YES;
}];

Related

UINavigationController undoes changes to previous UIView

I have a navigation controller with a couple of view controllers in it. In the first view controller (the app's initial one) I perform an animation, which moves two UIImageViews around, and fades in some additional ui elements. Now, when I push the next view controller and then go back to the initial one, the transformations are gone and the image views are exactly where they were when loaded from the storyboard. The additional ui elements, however, are still visible and so is the text I've entered in some UITextFields. So the view controller is not entirely reset to its initial state but somehow the performed animations are undone. Can anybody tell me whether this is regular behavior and - if so - how I can preserve the transformations?
A little more disclosure: I'm simply setting off a regular animation upon hitting a button...
[UIView animateWithDuration:0.4
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
self.firstView.center = firstCenter;
self.secondView.center = secondCenter;
}
completion:^(BOOL finished) {
// Upon complection fade in additional ui elements
[UIView animateWithDuration:0.4
animations:^{
self.firstElement.alpha = 1.0;
self.secondElement.alpha = 1.0;
self.thirdElement.alpha = 1.0;
}
completion:^(BOOL finished) {
[self.activityIndicator stopAnimating];
}];
}];
... and then pushing the next view controller after hitting another button.
[self.navigationController pushViewController:_nextViewController animated:YES];
As far as I can see I'm not doing anything funky here, so any help is appreciated.

View as POPUP in iPhone

I need to show a view(let us call it child view) as a popup on other view(let us call it parent view). The child view will contains images,labels and a button(TO dismiss the childView). I have googled for about an hour or so, but I am not really understanding on how to start the task. Kindly, help me with the approach,solution to resolve the issue.
Try this code.It will add a subview to your main view along with an animation:
//if you want to set your child view frame to your parent view frame.use this
self.childview.frame = self.view.frame;
//if not
self.childview.frame = CGRectMake(10,10,100,100);//ur own frame positon
self.childview.alpha = 0.0f;
[self.view addSubview:self.childview];
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationCurveEaseOut
animations:^{
self.childview.alpha = 1.0f;
}
completion:^(BOOL finished) {
}];
///After this..if you want to remove it.
[self.childview removeFromSuperview];
Hope this will help you.
use this Demo for your this requirement..
PopupView
In this Above demo you can access controls like UIButton ProgressBar,etc in your view from PopUPView This is Best Demo and SNPopupView class to use with its delegate method
also this is another demo
2 alpopoverview

UIView transitions

I am using ViewControllers for my different views, this is currently how I am switching from page to page:
- (IBAction)switchToSecondPage:(id)sender
{
SecondPage * secondPage = [[SecondPage alloc] initWithNibName:nil bundle:nil];
[self presentViewController: secondPage animated:YES completion:NULL];
}
This is the typical new view coming up from the bottom of the screen. I can use this to change the transition style, but I only get a couple choices to chose from, and none of them are any good.
secondPage.modalTransitionStyle = UIModalTransitionStylePartialCurl;
I am looking for transitions that are similar to the original one you get (page slides up from bottom). So I want 'slides down from top' and 'slides from left/right'. Is there any way I can do this. I see all sorts of applications doing this but I haven't been successful in finding anything.
One way to do this is,
[self.view addSubview:secondPage.view];
secondPage.view.frame = frameOutSideCurrentView;//Frame is set as outside the screen
[UIView animateWithDuration:1.0f
animations:^{
//actual frame needed with an animation.
secondPage.view.frame = originalFrame;
}
completion:^(BOOL finished) {
//if you need to anything specific once the animation is completed.
}];
Another way to do is by using this. TransitionController is custom implementation which helps to do this. In case you are facing issue with above code, use the category methods in this implementation. There are methods such as,
- (id)initWithViewController:(UIViewController *)viewController;
- (void)transitionToViewController:(UIViewController *)viewController
withOptions:(UIViewAnimationOptions)options;
which can be used to achieve this.

NavigationController UIToolbar Change Items

I want to change the items in my UIToolbar by hiding the toolbar, changing the items (button, fixed space, etc), and revealing it again.
I currently have a button on my UIToolbar that, when pressed, hides the toolbar by calling [[self navigationController]setToolbarHidden:YES animated:YES];.
How can I set these items? Is it possible using interface builder or do I need to hard-code them in?
This is non-standard behavior, but should be doable. You might consider instead of removing and adding new buttons to the existing toolbar, to instead create a different toolbar that gets faded in instead. This would make things easier to code/debug. In general, it just requires less "mess."
To achieve the desired behavior, you could do something like:
float animationDuration = .25;
[UIView animateWithDuration:animationDuration animations:*{
// Remove the old toolbar.
self.oldToolbar.alpha = 0;
// Fade the new toolbar in.
self.newToolbar.alpha = 1;
}];
This example assumes that you have already loaded your other toolbar into the newToolbar property. Let me know if you need further assistance or any explanation.
You can set new items for the toolbar this way:
[toolbar setItems:<new_items_array> animated:YES];
It will also animate the change so you may not need to hide and show it again, which is not a good UI practice in general.
A bit of an odd one... this is a bit hacky but should be perfectly fine:
[UIView animateWithDuration:0.5f animations:^{
// Remove the old toolbar.
self.oldToolbar.alpha = 0;
} completion:^(BOOL finished) {
//add code to change toolbar.
[UIView animateWithDuration:0.5f animations:^{
// Fade the new toolbar in.
self.newToolbar.alpha = 1;
}];
}];

UIView TransitionFromView disables scrolling

Hey there StackOverflow! I've finished programming my app, and everything is working fine- so I've decided that since the function part is done, I want to start working on form. However, I have a bit of code that's giving me trouble, and I'm not sure why. My app has two views that I switch between. In viewDidLoad, I have these two lines of code:
[PlannerView setScrollEnabled:YES];
[PlannerView setContentSize:CGSizeMake(320, 735)];
and then later, I switch between the main view and planner view when a button is pressed, like this:
if (isPlannerView) {
// [self setView:MainView];
[UIView transitionFromView:PlannerView
toView:MainView
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished){
[self setView:TimerView];
}];
isPlannerView = NO;
} else {
[UIView transitionFromView:MainView
toView:PlannerView
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished){
}];
// [self setView:PlannerView];
isPlannerView = YES;
}
Now, when I use hte commented line of code (self setview), it will scroll with no problems. However, when I use UIView transitionFromView, it no longer scrolls. Any idea what is going wrong here?
The documentation for transitionFromView:toView:duration:options:completion: says:
This method modifies the views in their view hierarchy only. It does
not modify your application’s view controllers in any way. For
example, if you use this method to change the root view displayed by a
view controller, it is your responsibility to update the view
controller appropriately to handle the change.
So make sure that viewDidLoad: is actually being called. It also states:
During an animation, user interactions are temporarily disabled for
the views being animated. (Prior to iOS 5, user interactions are
disabled for the entire application.) If you want users to be able to
interact with the views, include the
UIViewAnimationOptionAllowUserInteraction constant in the options
parameter.
So make sure that user-interaction is enabled on the view after the animation is finished.
completion:^(BOOL finished){
[PlannerView setUserInteractionEnabled:YES];
}];
Source: UIView Class Reference