UIPrintInteractionController inside popup - ios

I've to implement UIPrintInteractionController inside popup. I've implemented -
(UIViewController *)printInteractionControllerParentViewController:(UIPrintInteractionController *)printInteractionController {
UINavigationController* navigationController = [[UINavigationController alloc] init];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
[popover presentPopoverFromRect:address.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[popover.contentViewController.view setBackgroundColor:[UIColor grayColor]];
navigationController.preferredContentSize = CGSizeMake(320, 540);
return navigationController;
}
But it crashes saying :
reason: '-[UIPopoverController initWithContentViewController:] called when not running under UIUserInterfaceIdiomPad.'
Even on testing in ipad simulator. what to do ? I've to implement popup just like .

you can figure out the difference device whether it is iPad or iPhone using below code ..
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// code for iPad here
}else{
// code for iPhone here
}
updated
you can use custom view to popover using below method by passing a uiview to it.
-(void) popOver:(UIView *)view{
view.hidden = NO;
view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001); // view to popup
[UIView animateWithDuration:0.3
animations:^{
view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1
animations:^{
view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9,0.9); // custom view
}completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 animations:^{
view.transform = CGAffineTransformIdentity; // custom view to pop
}];
}];
}];
}
this method shows a uiview like popover now will be able to add any of the UI components over it.

Related

Animating the expansion of a UICollectionViewCell's content upon selection

How to animate the expansion of a UICollectionViewCell's content upon selection?
Currently I'm using transition animation on my didSelectItemAtIndexPath for animating a view Which isn’t working smoothly like AppStore card animation.
Here is my current code...
AnimateStaticImageViewController *animateImageVC = [[AnimateStaticImageViewController alloc] init];
animateImageVC.modalPresentationStyle = UIModalPresentationFullScreen;
animateImageVC.modelImage = [UIImage imageNamed:text];
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.3);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.7 animations:^{
animateImageVC.view.transform = CGAffineTransformIdentity;
}];
}];
}];
[self presentViewController:animateImageVC animated:NO completion:nil];
So, I was trying a modal transition animation in my app's home page staticImageCollectionView immediately after clicking the image.
The core animation & transform mechanism didn't work for me as I need something like AppStore's card animation.
Using this library worked after some hassle! Following this...
Setting the library with following steps.
Calling the transitioningDelegate of the animationViewController on didSelectItemAtIndexPath (or prepareForSegue if working with segue-navigation controller).
Calling it within a completion block to ignore flickering & delay issue in view presentation.
AnimatedStaticImageViewController *animateImageVC = [[AnimatedStaticImageViewController alloc] init];
animateImageVC.modalPresentationStyle = UIModalPresentationFullScreen;
animateImageVC.modelImage = [UIImage imageNamed:text];
[UIView animateWithDuration:0.2
animations:^{
animateImageVC.transitioningDelegate = self;
} completion:^(BOOL finished) {
[self.view removeFromSuperview];
[self presentViewController:animateImageVC animated:YES completion:nil];
}];
Be careful when setting imageView which is the main presentation of the animation.
Make sure you declaring the delegate 'RMPZoomTransitionAnimating' & 'RMPZoomTransitionDelegate' methods on both fromViewController and toViewController.

How to create a Slide Out Menu after login view using XIB in objective c

I am new in iOS and I am facing a problem regarding to create slide out menu.
I searched and found the example but all are for storyboard and which I found in xib are called on AppDelegate Class.
I need to create a Slide out menu in xib which should be call after login.
Thanks in Advance!
The best example of side bar menu is SWRevealViewController. This library is easy to use and its easy to understand.
This below work for me well...try in your code.
_parentView is your custom slide out view and _rightView (UIButton )is used to dismiss these custom slide out view. you just initialize these two property
#property (strong,nonatomic) UIView *parentView;
#property (strong,nonatomic) UIButton *rightView;
-(void)slideView
{
if(![_parentView isDescendantOfView:app.navController.view])
{
[self showMenu];
}
else
{
[self hideMenu];
}
}
-(void)showMenu
{
int width=[[UIScreen mainScreen]bounds].size.width;
int height=[[UIScreen mainScreen]bounds].size.height;
_parentView =[[UIView alloc]initWithFrame:CGRectMake(0-(width-70), 0, width-70, self.navigationController.view.frame.size.height)];
[_parentView setBackgroundColor:[UIColor lightTextColor]];
[app.navController.view addSubview:_parentView];
_rightView=[[UIButton alloc]initWithFrame:CGRectMake(0,80, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-80)];
_rightView.alpha=0.7;
[_rightView addTarget:self action:#selector(hideMenu) forControlEvents:UIControlEventTouchUpInside];
if(_parentView.frame.origin.x <0)
{
[self performSelector:#selector(showSideMenu) withObject:nil afterDelay:0.2];
}
}
-(void)showSideMenu{
if(_parentView.frame.origin.x <0)
{
[UIView animateWithDuration:0.5 animations:^{
[UIView animateWithDuration:0.7 animations:^{
[self.view addSubview:_rightView];
_rightView.backgroundColor=[UIColor blackColor];
}];
CGRect frame = _parentView.frame;
frame.origin.x =0;
_parentView.frame = frame;
CGRect rightFrame=self.view.frame;
rightFrame.origin.x=_parentView.frame.size.width;
self.view.frame=rightFrame;
CGRect fram1=app.navController.navigationBar.frame;
fram1 .origin.x =_parentView.frame.size.width;
app.navController.navigationBar.frame =fram1 ;
} completion:^(BOOL finished) {
}];
}
}
-(void)hideMenu
{
if(_parentView.frame.origin.x == 0)
{
[UIView animateWithDuration:0.3 animations:^{
CGRect frame = _parentView.frame;
frame.origin.x=-_parentView.frame.size.width;
_parentView.frame = frame;
CGRect fram=self.view.frame;
fram .origin.x=0;
self.view.frame =fram ;
CGRect fram1=app.navController.navigationBar.frame;
fram1 .origin.x =0;
app.navController.navigationBar.frame =fram1 ;
} completion:^(BOOL finished) {
[_rightView removeFromSuperview];
[_parentView removeFromSuperview];
}];
}
}
Thank you...!!!
PUSH FROM NORMAL VIEW CONTROLLER TO SW VIEW CONTROLLER
UIStoryboard*Storyboard=[AppDelegate storyBoardType];
SidebarViewController *sidebarmemu =(SidebarViewController*)[Storyboard instantiateViewControllerWithIdentifier:#"SidebarController"];
tbTBC*tabbarController=(tbTBC*)[Storyboard instantiateViewControllerWithIdentifier:#"tbTBCId"];
SWRevealViewController *revealController;
UINavigationController *frontNavigationController;
UINavigationController *rearNavigationController;
frontNavigationController =[[UINavigationController alloc]initWithRootViewController:tabbarController];
rearNavigationController =[[UINavigationController alloc]initWithRootViewController:sidebarmemu];
revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.delegate = self;
self.swcontroller =revealController;
self.view.window.rootViewController =self.swcontroller;
WITH THE HELP OF THIS CODE YOU CAN GET BOTH TAB BAR AS WELL AS SIDE BAR

Swipe Gesture with Custom Segue

I am currently using a modal segue in my storyboard to go from one view to another with a button. And on the way back I am using a button to run a custom segue with my ABCustomSegue. It is all working fine I just want to be able to run this custom segue after the user preforms a swipe. How might I achieve that?
ABCustomSegue:
-(void)perform{
UIViewController *sourceViewController = (UIViewController *) self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *) self.destinationViewController;
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, -sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.4
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, 0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view removeFromSuperview];
[sourceViewController presentViewController:destinationViewController animated:NO completion:nil];
}];
}
Current Swipe Recognizer:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UIScreenEdgePanGestureRecognizer *bezelSwipeGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:#selector(swipeBack:)];
bezelSwipeGestureRecognizer.edges = UIRectEdgeTop;
bezelSwipeGestureRecognizer.delegate = self;
[self.view addGestureRecognizer:bezelSwipeGestureRecognizer];
UIView *invisibleScrollPreventer = [UIView new];
invisibleScrollPreventer.frame = CGRectMake(0, 0, self.view.frame.size.width, 30);
[self.view addSubview:invisibleScrollPreventer];
}
-(void)swipeBack:(UIScreenEdgePanGestureRecognizer *)recognizer
{
if (recognizer.state == UIGestureRecognizerStateEnded) {
NSLog(#"swipe back");
}
}
Thank you!
Try this code:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

Is there any Way to Present a ViewController from Top without using Custom Classes?

I want to present a TableViewController from top on a button Click.I am able to present it using Custom Classes.Is there anyway to Present it without using Custom Classes so that it wont crash in iOS Versions?
popOverViewController = [[ACCPopoverViewController alloc] initWithStyle:UITableViewStylePlain];
[popOverViewController setTheMainArray:self.popoverListArray];
[popOverViewController setPopinTransitionStyle:BKTPopinTransitionStyleSpringySlide];//[self transitionStyleForIndexPath:0]];
if ([self isDismissable]) {
[popOverViewController setPopinOptions:BKTPopinDefault];
} else {
[popOverViewController setPopinOptions:BKTPopinDisableAutoDismiss];
}
[popOverViewController setDelegatePopOverIphone:self];
[popOverViewController setPopinTransitionDirection:BKTPopinTransitionDirectionTop];
[self.navigationController presentPopinController:popOverViewController animated:YES completion:^{
NSLog(#"Popin presented !");
}];
}
Here i am using a Custom PopOver...
then I used this to animate
[UIView animateWithDuration:0.5
delay:0.1
options: UIViewAnimationCurveEaseIn
animations:^{
self.popoverView.frame = CGRectMake(0, 0, 320, 460);
}
completion:^(BOOL finished){
}];
[self.view addSubview:self.popoverView];
but it shows some issues in ios 7.0 not in 7.1.
Donno why?
Checked the 6.0 and greater and i checked the constraints.
Pardon me if i am doing Wrong.Thanks in advance.

iOS 7 photos app like custom UIViewController Transition

I am a bit new to iOS development. I am working on an app that has about 5,000 visual data points, organized in categories. I want to present them in a UICollectionView with very tiny UICollectionViewCells. When a user taps on something in a category, the category zooms in with the selected cell in focus. Pretty much like how the "Photos" tab of the iOS 7 Photos app works: Years > Collections > Moments.
How do I go about implementing a custom transition like that? Are there any open-source libraries already written for accomplishing this?
If you can't find any library, try to play with this code I wrote for custom animations. You can specify a start point, an end point, start scale and end scale of a view that you want to zoom and scale in or out. See below an example how I use it. The point is to use a fake view to push it with animation, then push and pop your real view without animation. viewobj is set to fade in from alpha 0 to alpha 1, zoomableView will scale from the point/scale you give as parameter to the final position you set it in your storyboard/xib. Hope it will help.
# you can create a category vor UIView and add these methods
- (void) addSubView:(UIView*)viewObj animateFromPoint:(CGPoint)point zoomableView:(UIView*)view minScale:(CGSize)scale completion:(void (^)(void))completionBlock{
CGPoint center = view.center;
[view setTransform:CGAffineTransformMakeScale(scale.width, scale.height)];
viewObj.alpha = 0;
view.center = point;
[self addSubview:viewObj];
[self addSubview:view];
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
view.center = center;
[view setTransform:CGAffineTransformMakeScale(1.0, 1.0)];
viewObj.alpha = 1;
}
completion:^(BOOL fin){
if(completionBlock)
completionBlock();
}];
}
- (void) removeFromSuperviewAnimateToPoint:(CGPoint)point zoomableView:(UIView*)view minScale:(CGSize)scale completion:(void (^)(void))completionBlock{
CGRect startFrame = view.frame;
self.alpha = 1;
[self.superview addSubview:view];
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
view.center = point;
[view setTransform:CGAffineTransformMakeScale(scale.width, scale.height)];
self.alpha = 0;
}
completion:^(BOOL fin){
[self removeFromSuperview];
[view removeFromSuperview];
[view setTransform:CGAffineTransformMakeScale(1, 1)];
view.frame = startFrame;
[self addSubview:view];
if(completionBlock)
completionBlock();
}];
}
And to use them:
# your did select item at index path:
self.itemDetails = [self.storyboard instantiateViewControllerWithIdentifier:#"ItemDetailsVC"];
ItemDetailsVC* itd = [self.storyboard instantiateViewControllerWithIdentifier:#"ItemDetailsVC"];
__weak UIViewController* wself = self;
[self.view addSubView:self.itemDetails.view animateFromPoint:self.zoomedFrom zoomableView:self.itemDetails.viewZoomable minScale:CGSizeMake(0.371134, 0.371134) completion:^{
[wself.navigationController pushViewController:itd animated:NO];
}];
self.addSubviewIsUp = YES;
# back button of the view you added:
[self.navigationController popViewControllerAnimated:NO];
# viewdidapear of your main screen
if(self.addSubviewIsUp){
[self.addVc.view removeFromSuperviewAnimateToPoint:CGPointMake(160, 75) zoomableView:self.addVc.zoomableView minScale:CGSizeMake(0.01, 0.01) completion:^{
}];
}
self.addSubviewIsUp = NO;

Resources