Objective C Segues, dissolve programmatically - iphone

I have two classes, machineClass and buttonsClass... From buttons class, I want a button to programmatically push into the machineClass.
Ive gotten that to work with:
machineClass *mc = [self.storyboard instantiateViewControllerWithIdentifier:#"machineClass"];
mc.passedString = purchase;
[self presentViewController:mc animated:YES completion:nil];
However, this uses the default segue animation (where the view comes up vertically), and I think my app would look so much nicer if I used the cross dissolve transition instead.
Can anyone help? The best solution I've come up with is to change it to:
[self presentViewController:mc animated:NO completion:nil];
But I don't like this as much...
Thanks!

You can set the target view controller's modal transition style in the storyboard. Or in code:
machineClass *mc = [self.storyboard instantiateViewControllerWithIdentifier:#"machineClass"];
mc.passedString = purchase;
mc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:mc animated:YES completion:nil];

Related

AQGridView - Orientation change in ExpanderDemo

I just started checking AQGridView and new to iOS too in the source example ExpanderDemo the orientation is working fine for the first View but as i click any cell and next upcomming AQGridView does not effect View on GridView.
ExpandingGridViewController *controller = [[ExpandingGridViewController alloc] init];
controller.gridView.frame = self.gridView.frame;
[self.gridView setHidden:YES];
[self.view.superview addSubview: controller.gridView];
[controller expandCellsFromRect: expandFromRect ofView: cell];
[controller viewDidAppear: NO];
On the other hand if i present the view controller to second it works fine with the orientation but losses the Animation for Expansion; which i don't want to loose. What should i do?
ExpandingGridViewController *controller = [[ExpandingGridViewController alloc] init];
[self presentViewController:controller animated:NO completion:nil];
The last time I use AQGridView I got a lot of troubles, I suggest You should give a try to UICollectionView. Cheers!

Objective-c: presentViewController from UIView

Im trying to use presentViewController inside a UIView.
http://img145.imageshack.us/img145/6334/appt.png
When I click he "+" button at the top/right, I want to replacer the tableview at the right (in the grey part of the image) by a UIViewController.
- (void)add:(id)sender
{
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:#"testview"];
[self presentViewController:controller animated:YES completion:NULL];
}
Of course by doing this, the whole screen is replaced..
I want something like this:
[contentView addSubview:controller];
or
[contentView presentViewController:controller animated:YES completion:NULL];
where contentView is an UIView containing the tableview
I found this addChildViewController and presentViewController but I don't think that can help me out
Thanks
EDIT:
Use ContainerView in storyboard solved my problem
You can add the controller's view as a subview of your contentView. Be sure to keep a strong reference to the controller when you do that though.
Another approach would be to make the new view owned by the presenting controller instead of a second controller and simply hide/show views as needed.
edit your statement:
[self.navigationController presentViewController:controller animated:YES completion:NULL];
try this and then let me know if it worked!
I am not sure if I understand you right. From your picture I believe you are programming for an iPad, and you want to cover the whole view partly by another view. If so, you could use a UIPopoverController, which does exactly this.
A PopoverController seems to be what you need. Here is some boilerplate code:
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:navigation];
self.aPopoverController = aPopover;
[self.aPopoverController presentPopoverFromRect:nil inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
aPopoverController is a property of the class.
#property UIPopoverController* aPopoverController;
If I understand clearly. This would help you out
SomeViewController *viewController=[[SomeViewController alloc]init];
[viewController setFrame:CGRectMake(x,y,width,height)];
[self.view addsubview:viewController.view];
Sorry if Iam wrong...

PresentViewController from AppDelegate

I am trying to present a ViewController which I know can be done with the following line.
[self presentViewController:myVC animated:YES completion:nil];
However I have a part which is calling the AppDelegate and that is where I run into trouble.
I can manage to sort it out with:
[self.navigationController pushViewController:bvc animated:YES];
but as the code implies, this does a navigation push - how do I it, so that I can do a vertical push up?
You can present on navigation controller -
[self.navigationController presentViewController:myVC animated:YES completion:nil];

Form Sheet Modal View Animations

I have UIModalPresentationFormSheet views appearing in my app. Some of them appear from the Right some from the Bottom and the dismissing seems random. Some disappear to the Bottom some go Left some go Up. Is there a way to set the direction they appear from and dismiss to?
Code I use to present (this same code, just different viewcontroller being presented, called from the same view controller has varying animations for different modal views):
MyViewController *newModalView = [[MyViewController alloc] init];
newModalView.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:newModalView animated:YES];
Then in the modal view I call this to dismiss it:
[self dismissModalViewControllerAnimated:YES];
This is a known bug and is being worked on by apple.
Try something like this:
newModalView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
All the transition Styles:
newModalView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
newModalView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
newModalView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

Can a UIPopoverController be moved around the screen?

Is it possible to move a UIPopovercontroller around the screen once its already been presented?
I have a small view in my app that can move slightly, and I would like a UIPopoverController to move around with it without having to re-present the UIPopoverController every time it moves. Is this possible?
As of iOS 9, "UIPopoverController is deprecated. Popovers are now implemented as UIViewController presentations. Use a modal presentation style of UIModalPresentationPopover and UIPopoverPresentationController."
Use the following to present a popover. You may be able to change the values of sourceRect and sourceView but this isn't intended API behavior.
DetailViewController *detailVC = self.detailViewController;
detailVC.preferredContentSize = CGSizeMake(420, 92);
detailVC.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *presController = detailVC.popoverPresentationController;
if (presController) {
presController.delegate = detailVC;
presController.barButtonItem = self.detailButton;
presController.sourceRect = self.view.frame;
presController.sourceView = self.view;
presController.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
[self presentViewController: detailVC animated:YES completion:^{
}];
Instead, I suggest keeping a reference to the view controller presented with the popover, dismiss the popover and re-present.
DetailViewController *detailVC = self.detailViewController;
[self dismissViewControllerAnimated:NO completion:^{
UIPopoverPresentationController *presController = detailVC.popoverPresentationController;
if (presController) {
presController.delegate = detailVC;
presController.barButtonItem = self.detailButton;
presController.sourceRect = self.view.frame; //Update frame
presController.sourceView = self.view;
presController.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
[self presentViewController: detailVC animated:NO completion:^{
}];
}];
You can re-call presentPopoverFromRect.
See http://developer.apple.com/library/ios/#qa/qa1694/_index.html
No you can't. This is no method to do that.
pover presentPopoverFromRect:
was mentioned in the comments, but notice the
present
you cannot represent without redrawing.
You can track the users touches around the screen, and use presentPopoverFromRect: to reshow the popover.