May be this Question may be duplicate but i really need your help..
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
NewFeedDetailVC *nextViewController = [[NewFeedDetailVC alloc] initWithNibName:#"NewFeedDetailVC" bundle:[NSBundle mainBundle]];
nextViewController.originRect = imgFrame;
nextViewController.currentscrolloffset=aStylizedView.contentOffset.y;
[window addSubview:nextViewController.view];
[UIView animateWithDuration:0.5
animations:^{
nextViewController.view.frame = CGRectMake(0, 20, 320, ScreenHeight-20);
}
completion:^(BOOL finished){
}];
above is demo code i have tried to make zoom animation before push ..
imgFrame is image on which user will tap
When user click right top orange (four square) button ,and code as below
[UIView animateWithDuration:0.5
animations:^{
self.view.frame=self.originRect;
}
completion:^(BOOL finished){
[test removeFromSuperview];
[self.view removeFromSuperview];
}];
view should be pop out with zoom in animation to there parent frame but i am not able to perform smooth transition and image suppose to be same as parent frame and just black view is scaling to original frame, and another issue is you can observe animation is not clipping out in navigation control even if Its frame is clipping in original scroll view.
Thanks
Related
Here is what I currently have: http://cl.ly/PIFB
And the code behind it:
UIView *smallView = [[_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:recognizer.view.tag inSection:0]] contentView];
CGRect initialSize = smallView.frame;
CGRect finalSize = CGRectMake(150.0, 100.0, 660.0, 450.0);
UIView *largeView = [[UIView alloc] initWithFrame:initialSize];
[largeView setBackgroundColor:[UIColor blackColor]];
[largeView setClipsToBounds:NO];
[UIView transitionFromView:smallView toView:largeView duration:2 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
[[_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:recognizer.view.tag inSection:0]] contentView].frame = finalSize;
[largeView setFrame:finalSize];
[smallView removeFromSuperview];
[self addSubview:largeView];
[UIView animateWithDuration:2 animations:^{
smallView.frame = finalSize;
[largeView setFrame:finalSize];
}];
}];
Basically I have a UITableView of views. When one of those views is tapped I would like to scale and flip it at the same time so that it shows a new larger view in the center of the screen. Currently it flips the smaller view and eventually shows the larger view at the right size but it doesn't transition smoothly.
In the code above smallView is the currently tapped cells content view. largeView is the new view that will eventually be developed to show more data relevant to the cell that was tapped. Right now it is represented by the black view. I really would like the small cell to grow and flip at the same time so that it smoothly transitions into the larger view.
Your help would be greatly appreciated. My experience with objective c, cocoa touch, and performing animations is pretty limited.
Thanks so much.
I finally figured it out. See here: http://cl.ly/PQqP
It required me to do two separate UIView transitionWithView methods:
[_transitionView addSubview:smallView];
[smallView setFrame:CGRectMake(0, 0, _transitionView.frame.size.width, _transitionView.frame.size.height)];
[UIView transitionWithView:_transitionView duration:.5 options:UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionCurveEaseOut animations:^(){
[UIView transitionWithView:cellView duration:.25 options:UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionCurveEaseIn animations:^(){
[cellView setFrame:smallViewOrigin];
} completion:NULL];
_transitionView.frame = finalSize;
smallView.frame = smallViewOrigin;
[_transitionView insertSubview:metricModalViewController.view belowSubview:smallView];
[smallView removeFromSuperview];
metricModalViewController.view.frame = metricModalEndSize;
} completion:^(BOOL finished) {
[_transitionView setFinalView:metricModalViewController.view];;
}];
It looks like you should use transitionWithView:duration:options:animations:completion: instead. Like this:
[UIView transitionWithView:self
duration:2
options:UIViewAnimationOptionTransitionFlipFromRight|UIViewAnimationOptionAllowAnimatedContent
animations:^(){
smallView.frame = finalSize;
[smallView removeFromSuperview];
[self addSubview:largeView];
largeView.frame = finalSize;
}
completion:NULL];
That might flip the self view, which might not look exactly right. If that's a problem, then add an extra view in your hierarchy which does nothing but contain smallView or largeView at the same size as them. Set the frame of that view in addition to those of the smallView and largeView. (Or just set the container view transform, or just set the container view frame and configure appropriate autoresizing options for the smallView and largeView.)
Maybe try this. Set up a view containerView that is a child of self and initially contains smallView. Make the frame of containerView what you initially had for smallView. Make the size of smallView the same as the size of containerView but the origin (0,0) so that smallView fills containerView entirely.
[UIView transitionWithView:containerView
duration:2
options:UIViewAnimationOptionTransitionFlipFromRight|UIViewAnimationOptionAllowAnimatedContent
animations:^(){
containerView.frame = finalSize;
smallView.frame.size = finalSize.size;
[smallView removeFromSuperview];
[containerView addSubview:largeView];
largeView.frame.size = finalSize.size;
}
completion:NULL];
I'm just guessing, again.
I am try to create an animation in my app which would slide up a frame to my desired position. The frame would be having other buttons and text on it as well.
I was unable to use actionsheet for this, as it starts from the bottom most part of the window. What i want to create is shown in the picture below.
the frame I want to animate is the one with Capture mode: text.
Click on the button on the tabView I want this frame to slide up, starting from the top of the tabview. and again clicking the button should make the frame disappear.
So far my code looks like
-(IBAction)setting
{
NSLog(#"finalShare Button");
UIView *tempView;
CGRect tmpFrame;
tempView = [[[UIView alloc] initWithFrame:CGRectMake(0, 490, 320, 90)]
autorelease];
[tempView setBackgroundColor:[UIColor clearColor]];
[tempView setAlpha:.87];
tempView.hidden = YES;
[self.view addSubview:tempView];
tmpFrame = tempView.frame;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.75];
tmpFrame.origin.y=390;
self.view.frame=tmpFrame;
[UIView commitAnimations];
}
The problem I am facing here is that when I animate my frame to move, the main view moves along with it. Which is something I don't want it to do.
I am new to iPhone programming, please guide how can I fix this.
Or what would be a better way to do it.
Thanks
You don't need to make the view hidden, just add it as a subview after you set its frame to have y origin of 480. Also, don't use the old UIView animation methods; use blocks.
Here's an example of a view that starts with a y origin of 0. It gets positioned at negative y equal to its height, added as a subview then animated down to meet the keyboard coming up from the bottom of the screen.
// add to view while completely off-screen
CGRect unlockViewFrame = unlockView.frame;
unlockViewFrame.origin.y = -unlockViewFrame.size.height;
unlockView.frame = unlockViewFrame;
[self.view addSubview:unlockView];
unlockViewFrame.origin.y = 0.;
[UIView animateWithDuration:0.3 animations:^{
unlockView.frame = unlockViewFrame;
}];
Here's the same thing in reverse, using a completion block to remove the view.
unlockViewFrame.origin.y = -unlockViewFrame.size.height;
[UIView animateWithDuration:0.3 animations:^{
view.frame = unlockViewFrame;
} completion:^(BOOL completion) {
[view removeFromSuperview];
}];
Another thing I notice is that you are doing everything in code; consider doing it in Interface Builder. A smart man once told me that code you don't write can't have any bugs and he was right. It's easy to create a view in IB and instantiate it inyour code when you need it:
NSArray* nibViews;
nibViews = [[NSBundle mainBundle] loadNibNamed:#"UnlockView" owner:self options:nil];
UnlockView *unlockView = [nibViews objectAtIndex:0];
Also, consider using ARC. No more autorelease!
Your resetting frame of main view and not tempView
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.75];
tmpFrame.origin.y=390;
tempView.frame=tmpFrame; //it should be tempView not self.view ie main view
[UIView commitAnimations];
How to perform a sliding animation when a view is being loaded in an iPhone application?
I have a ViewController in which I have subview. I want that the subview be loaded with an animation, sliding from the left to the right.
I got this code so far:
-(void) showAnimation{
[self.view addSubview:geopointView]
geopointView.frame = CGRectMake(20,150,550,200)// somewhere offscreen, in the direction you want it to appear from
[UIView animateWithDuration:10.0
animations:^{
geopointView.frame = CGRectMake(20,150,550,200)// its final location
}];
}
why not?
-(void) showAnimation{
[self.view addSubview:geopointView]
geopointView.frame = CGRectMake(-200,150,550,200)// just set a different frame
[UIView animateWithDuration:10.0
delay:0.0
options:UIViewAnimationCurveEaseOut
animations:^{
geopointView.frame = CGRectMake(20,150,550,200)// its final location
}
completion:nil];
}
I have a view controller....when the user presses a button I want a black screen to fade in over the top and a uiactivityindicator to appear on top of the faded screen.
How can I get this animated fade in effect?
-(IBAction) loginToApp:(id)sender{
//fade in view
}
Add another view over the top of your view, colored solid black. You can do it in IB or programatically, just make sure it has a higher z-order (is on top). Make its alpha = 0. Then:
-(IBAction) loginToApp:(id)sender{
[UIView animateWithDuration:1.5 animations:^{ myview.alpha = 1.0; }]
}
...obviously you need an outlet or variable myview connected to that view. 1.5 = seconds. Change for your needs.
Sure you can. You can create the overlay view however you wish, but this will work (assuming you create appropriate instance variables somewhere). My code was in my view controller, so [self view] returns the view I want to shade over.
shadeView = [[UIView alloc] initWithFrame:[[self view] bounds]];
shadeView.backgroundColor = [UIColor blackColor];
shadeView.alpha = 0.0f;
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorStyleWhiteLarge];
spinner.center = CGPointMake(CGRectGetMidX([shadeView bounds]),
CGRectGetMidY([shadeView bounds]));
[shadeView addSubview:spinner];
[[self view] addSubview:shadeView];
To present:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[spinner startAnimating];
shadeView.alpha = 0.7f;
[UIView commitAnimations];
And to hide:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[spinner stopAnimating];
shadeView.alpha = 0.0f;
[UIView commitAnimations];
I am working to force a view into landscape mode, and have picked up all kinds of cool tips to make this happen, but am stuck on one item that is left on the screen.
I have my XIB file laid out in landscape, and in my code I create the view controller normally:
RedeemViewController *aViewController = [[RedeemViewController alloc] initWithNibName:#"RedeemViewController" bundle:nil];
aViewController.hidesBottomBarWhenPushed = YES;
aViewController.wantsFullScreenLayout = YES;
[[self navigationController] pushViewController:aViewController animated:YES];
Inside the controller viewDidLoad I complete the following:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
[[self navigationController] setNavigationBarHidden:YES animated:YES];
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:.75];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
if (self.interfaceOrientation == UIInterfaceOrientationPortrait) {
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
}
[UIView commitAnimations];
What I end up with is a perfectly rotated view, with a grey vertical bar on the left side (see pic).
alt text http://taxhelp.net/vert_bar.png
So to the question, how do I get rid of the bar?
Edit: I am pretty sure this is the navigation bar that is not being hidden.
Your bounds rectangle is created with the origin at (0, -20). Change that to (0, 0) and you should be rid of the offset and have the view filling the screen.