Quartz animation error - ios

I have included the <QuartzCore/QuartzCore.h> framework.
On an IBAction I have this:
- (IBAction)searchOptions:(id)sender {
FilterViewController *ctrl = [[FilterViewController alloc] initWithNibName:#"FilterViewController" bundle:nil];
[UIView transitionFromView:self.view toView:ctrl.view duration:1 options:UIViewAnimationOptionTransitionCurlUp completion:nil];
[self.navigationController pushViewController:ctrl animated:NO];
}
When I click the button, the page curls up as you would expect:
When I click the next button (which should curl the page back down) I get this error:
Thread 1: EXC_BAD_ACCESS(code=2, address=0x8)
I think the problem is with the above action (not with the action to uncurl).
What has gone wrong?
EDIT: After a further hour of reading - could it be a memory problem?

I'm not sure but I don't think UIView retains the controller you're passing into it. Assuming you're using ARC, you could try making the FilterViewController into a property.
i.e. In the header add this:
#class FilterViewController;
#interface YourViewController : UIViewController {
FilterViewController *_filterViewController;
}
Then in the implementation change it to:
_filterViewController = [[FilterViewController alloc] initWithNibName:#"FilterViewController" bundle:nil];
[UIView transitionFromView:self.view _filterViewController duration:1 options:UIViewAnimationOptionTransitionCurlUp completion:nil];
[self.navigationController pushViewController:_filterViewController animated:NO];
To make sure it gets retained.

Isn't really mandatory for you to do Page curling effect?
[Try this first]
- (IBAction)searchOptions:(id)sender {
FilterViewController *ctrl = [[FilterViewController alloc] init];
ctrl.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:ctrl animated:YES];
}

Related

IOS/Objective-C: call of another class(VC) method not working

I've searched and searched for the answer to this issue and the solutions i've found doesn't seem to work, so I guess i'm doing something wrong: i want to call this method
-(void)customFade:(UILabel *)theLabel withDelay:(float)delayAmount {
[UIView animateWithDuration:0.5
delay:delayAmount
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[theLabel setAlpha:1.0f];
[theLabel setAlpha:0];
}completion:nil];
}
from a VC called View Controller to another but it isn't being recognized despite the imports... here's what i'm trying on the desired VC:
- (void)viewDidLoad {
[super viewDidLoad];
ViewController *ViewController = [[ViewController alloc] init];
[ViewController customFade:_label withDelay:0.3];
}
the warning says "no visible #interface for "ViewController" declares the selector alloc
Can someone help me out? I'm kind of new at this, thank you
such an error usually happens when you have mistyped the name of the method, or that method doesn't belong to that class at all and doesn't exist in your class.
and ensure once your VC is subclass with UIViewController
#interface ViewController : UIViewController
change your instance object type and check once
ViewController *vc = [[ViewController alloc] init];
[vc customFade:_label withDelay:0.3];
and change the animation like
[UIView animateWithDuration:0.5
delay:delayAmount
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[theLabel setAlpha:1.0f];
}completion:{
[theLabel setAlpha:0];
}];
for more information you can get the reference from here

UIPopovercontroller doesn't show anything on iPad Simulator(xCode6.1)

I am trying to show the UIPopovercontroller that involves UIPickerView when I click a button on iPad. I can see the UIPopovercontroller but I can't see the UIPickerView in UIpopovercontroller
I've already made a ViewController which has the UIPickerViewer in storyboard for UIPopovercontroller.
So what am I missing now?
Here are the code I am using.
#property (nonatomic, strong) UIPopoverController *userDataPopover;
- (IBAction)setTime:(id)sender {
DatePickerViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:#"datePickerView"];
viewController.delegate = self;
self.userDataPopover = [[UIPopoverController alloc] initWithContentViewController:viewController];
self.userDataPopover.popoverContentSize = CGSizeMake(400, 400);
[self.userDataPopover presentPopoverFromRect:[(UIButton *)sender frame]
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES]; }
Try these
0 - Check height of date picker.
1 - Check constraints if you have any.
2 - Can you try to add DatePicker directly to popover controller
when I use following code, it works well.
DatePickerViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:#"datePickerView"];
[self presentViewController:viewController animated:YES completion:nil]
But there is a problem when I use Popovercontroller.

Storyboard Segue Transition Effects

First time poster, long time observer.
I am using storyboards for an app I am working on at present, and require more of a transition than just going forward, for going back in particular. Whenever i use this segue i have for going back through a menu, the next button that is clicked on to go to another ViewController, will crash the whole app!
No idea whats going on, i am using this in the implementation file
#import "SlideLeftSegue.h"
#implementation SlideLeftSegue
- (void)perform{
UIView *sv = ((UIViewController *)self.sourceViewController).view;
UIView *dv = ((UIViewController *)self.destinationViewController).view;
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
dv.center = CGPointMake(sv.center.x - sv.frame.size.width, dv.center.y);
[window insertSubview:dv belowSubview:sv];
[UIView animateWithDuration:0.4
animations:^{
dv.center = CGPointMake(sv.center.x,
dv.center.y);
sv.center = CGPointMake(sv.center.x + sv.frame.size.width,
dv.center.y);
}
completion:^(BOOL finished){
[[self destinationViewController]
dismissViewControllerAnimated:NO completion:nil];
}];
}
#end
This is my header file
#import <UIKit/UIKit.h>
// Move to the previous screen with slide animation.
#interface SlideLeftSegue : UIStoryboardSegue
#end
I am still learning, so if you have any idea whats happening, id appreciate an explanation at a beginner level.
You can achieve that with less code
To present a view controller:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:#"ViewID"];
view.modalTransitionStyle = UIModalTransitionStyleCoverVertical; // you can try the other 3 UIModalTransitionStyle too
[self presentViewController:view animated:YES completion:nil];
To go back:
[self dismissViewControllerAnimated:YES completion:nil];

Inherited view controller will not dismiss itself in a block #ICETutorial

I'm using ICETutorial with cocoapods.
I'm using it in a SettingsViewController where you can view the tutorial in settings.
// SettingsViewController.m
Tutorial2ViewController *vc = [[Tutorial2ViewController alloc] init];
[self.navigationController setNavigationBarHidden:YES animated:NO];
[self.navigationController pushViewController:vc animated:NO];
And Tutorial2ViewController inherits from ICETutorialController
#interface Tutorial2ViewController : ICETutorialController
ICETutorialPages have buttons that will trigger a callback. It takes in a block. So in my implementation, I have this:
- (id)init
{
ICETutorialPage *layer1 = [[ICETutorialPage alloc] initWithSubTitle:#"Page 1" description:#"Page 1" pictureName:#"Tutorial1_640x1136.png"];
NSArray *tutorialLayers = #[layer1];
self = [super initWithNibName:#"ICETutorialController_iPhone" bundle:nil andPages:tutorialLayers];
__weak Tutorial2ViewController *vc = self;
[self setButton1Block:^(UIButton *button){
NSLog(#"Button 1 pressed.");
[[vc.navigationController topViewController] dismissViewControllerAnimated:NO completion:nil];
}];
if (self != nil)
{
}
return self;
}
The reason why I put all the code in init is that I don't want SettingsViewController to know anything about how the Tutorial2ViewController works. Settings should alloc and init, push to the navigation controller stack and the Tutorial2ViewController should know how to handle itself.
I do get the NSLog that button1 is pressed but the view controller does not dismiss itself and return me to the SettingsViewController.
I will contact the creator of the library and ask him/her to see this question also. I feel that this is me not misunderstanding blocks, navigation controllers, cocoapods, etc...
Thanks
Just try [self.navigationController popViewControllerAnimated:YES];

Muiltple Modal UIViewControllers | Dismiss Top Modal UIViewController Only

My UIViewController stack looks as follows:
+------ UIViewController_C (presented)
+---- UIViewController_B (presented)
+-- UIViewController_A (pushed)
When I call -dismissViewController:animated on UIViewController_C, UINavigationController dismisses both UIViewController_C and UIViewController_B together, as per the docs with animation on _C, and none on _B.
What is the most compliant way to dismiss _C only?
try as below
after pushing to UIViewController_A present UIViewController_B as below code.
UIViewController_B *bbp=[[UIViewController_B alloc]initWithNibName:#"UIViewController_B" bundle:nil];
UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:bbp];
passcodeNavigationController.navigationBar.hidden=YES;
[self.navigationController presentModalViewController:passcodeNavigationController animated:YES];
[passcodeNavigationController release];
now from UIViewController_B try to present in UIViewController_C as below code.
UIViewController_C *bbp=[[UIViewController_C alloc]initWithNibName:#"UIViewController_C" bundle:nil];
UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:bbp];
passcodeNavigationController.navigationBar.hidden=YES;
[self.navigationController presentModalViewController:passcodeNavigationController animated:YES];
[passcodeNavigationController release];
last and final thing on every back button of view controller write below line of code.
[self dismissModalViewControllerAnimated:YES];
if you want more help than comment bellow.
One Solution:
UIViewControllers presented modally are not necessarily deallocated on -dismissViewController:animated.
This means that by passing a reference to UIViewController_A through _B to _C, you can call -presentViewController:animated and -dismissViewController:animated for the respective UIViewControllers via UIViewController_A.
Code:
1. UIViewController_B
- (void) showUIViewController_C {
[self dismissViewControllerAnimated:TRUE completion:^{
UIViewController_C *controller_C = [[UIViewController_C alloc] init];
controller_C.parentController = self;
[self.parentController controller_C animated:TRUE completion:nil];
}];
}
2. UIViewController_C
- (void) dismissUIViewController_C {
[self dismissViewControllerAnimated:TRUE completion:^{
[self.parentController.parentController presentViewController:self.parentController animated:TRUE completion:nil];
}];
}
Where I am using *parentController as the naming convention for whatever class your previous UIViewController on the stack may be.
It dips back to UIViewController_A briefly because I am calling -dismiss and -present in the completion block, though that actually looks rather fun.

Resources