iOS Share Extension not presenting my custom ShareViewController - ios

I cant seem to present my custom ShareViewController. I inherited UIViewController, not SLComposeViewController, added it to the Storyboard, but when i select an image to share, ShareViewController is not presented. Here is my entire code:
Header file:
#import <UIKit/UIKit.h>
#import <Social/Social.h>
#interface ShareViewController : UIViewController
#end
Implementation file:
#implementation ShareViewController
- (void)viewDidLoad{
[super viewDidLoad];
self.view.alpha = 0;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.view.transform = CGAffineTransformMakeTranslation(0, self.view.frame.size.height);
[UIView animateWithDuration:0.25 animations:^
{
self.view.transform = CGAffineTransformIdentity;
}];
}
- (void)dismiss
{
[UIView animateWithDuration:0.20 animations:^
{
self.view.transform = CGAffineTransformMakeTranslation(0, self.view.frame.size.height);
}
completion:^(BOOL finished)
{
[self.extensionContext completeRequestReturningItems:nil completionHandler:nil];
}];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:YES];
for (NSItemProvider* itemProvider in ((NSExtensionItem*)self.extensionContext.inputItems[0]).attachments )
{
if([itemProvider hasItemConformingToTypeIdentifier:#"public.image"])
{
[itemProvider loadItemForTypeIdentifier:#"public.image" options:nil completionHandler:
^(id<NSSecureCoding> item, NSError *error)
{
UIImage *sharedImage = nil;
if([(NSObject*)item isKindOfClass:[NSURL class]])
{
sharedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:(NSURL*)item]];
}
if([(NSObject*)item isKindOfClass:[UIImage class]])
{
sharedImage = (UIImage*)item;
}
}];
}
}
}
#end
Breakpoint indicates that runtime does execute the code, even grabs image, but the custom view controller is not presented for some reason. Any help?

It was so stupid and it took me a while to figure it out, but for some reason, by default, custom ShareViewController view's background color is set to [UIColor clearColor]. Very stupid of Apple :), but i solved this case

Related

How to dismis Viewcontroller (popup) by pressing button inside my popup viewcontroller and also touch any where outside of viewcontroller?

I have one viewcontroler with one button.When i press that one pop up viewcontroller will show up.And when i touch anywhere outside it dismiss the viewcontroller .And return to my main viewcontroller.
Note
I used my popup through one viewcontroller and i use identifier name .Then i show pop up using that storyboard identifier and declared in my viewcontroller.m in btnSelectDatePressed
Needed
in that pop up view controller i have one button when user press also it should dismiss the viewcontroller and should return to my main viewcontroller.My example image is like this sample image
This is my viewcontroller.m file
#import "ViewController.h"
#import "UIViewController+ENPopUp.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)btnSelectDatePressed:(id)sender
{
UIViewController *vc = [[UIStoryboard storyboardWithName:#"Main" bundle:nil] instantiateViewControllerWithIdentifier:#"PopUp"];
vc.view.frame = CGRectMake(0, 0, 309.0f, 531.0f);
[self presentPopUpViewController:vc];
}
This is my popup method declared in #import "UIViewController+ENPopUp.h"
#import <UIKit/UIKit.h>
#interface UIViewController (ENPopUp)
#property (nonatomic, retain) UIViewController *en_popupViewController;
- (void)presentPopUpViewController:(UIViewController *)popupViewController;
- (void)presentPopUpViewController:(UIViewController *)popupViewController completion:(void (^)(void))completionBlock;
- (void)dismissPopUpViewController;
- (void)dismissPopUpViewControllerWithcompletion:(void (^)(void))completionBlock;
//- (IBAction)disMe:(id)sender;
#end
This is my popup method declared in `#import "UIViewController+ENPopUp.m"`
#import "UIViewController+ENPopUp.h"
#import "JWBlurView.h"
#import <objc/runtime.h>
static void * ENPopupViewControllerPropertyKey = &ENPopupViewControllerPropertyKey;
static CGFloat const kAnimationDuration = .4f;
static CGFloat const kRotationAngle = 70.f;
static NSInteger const kENPopUpOverlayViewTag = 351301;
static NSInteger const kENPopUpViewTag = 351302;
static NSInteger const kENPopUpBluredViewTag = 351303;
#implementation UIViewController (ENPopUp)
#pragma mark - Public Methods
- (void)presentPopUpViewController:(UIViewController *)popupViewController
{
[self presentPopUpViewController:popupViewController completion:nil];
}
- (void)presentPopUpViewController:(UIViewController *)popupViewController completion:(void (^)(void))completionBlock
{
self.en_popupViewController = popupViewController;
[self presentPopUpView:popupViewController.view completion:completionBlock];
}
- (void)dismissPopUpViewController
{
[self dismissPopUpViewControllerWithcompletion:nil];
}
- (void)dismissPopUpViewControllerWithcompletion:(void (^)(void))completionBlock
{
UIView *sourceView = [self topView];
JWBlurView *blurView = (JWBlurView *)[sourceView viewWithTag:kENPopUpBluredViewTag];
UIView *popupView = [sourceView viewWithTag:kENPopUpViewTag];
UIView *overlayView = [sourceView viewWithTag:kENPopUpOverlayViewTag];
[self performDismissAnimationInSourceView:sourceView withBlurView:blurView popupView:popupView overlayView:overlayView completion:completionBlock];
}
//- (IBAction)disMe:(id)sender {
// UIViewController *vc = [[UIStoryboard storyboardWithName:#"Main" bundle:nil] instantiateViewControllerWithIdentifier:#"Pop"];
// [self dismissViewControllerAnimated:YES completion:Nil];
//}
#pragma mark - Getters & Setters
- (UIViewController *)en_popupViewController
{
return objc_getAssociatedObject(self, ENPopupViewControllerPropertyKey);
}
- (void)setEn_popupViewController:(UIViewController *)en_popupViewController
{
objc_setAssociatedObject(self, ENPopupViewControllerPropertyKey, en_popupViewController, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
#pragma mark - View Handling
- (void)presentPopUpView:(UIView *)popUpView completion:(void (^)(void))completionBlock
{
UIView *sourceView = [self topView];
// Check if source view controller is not in destination
if ([sourceView.subviews containsObject:popUpView]) return;
// Add overlay
UIView *overlayView = [[UIView alloc] initWithFrame:sourceView.bounds];
overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
overlayView.tag = kENPopUpOverlayViewTag;
overlayView.backgroundColor = [UIColor clearColor];
// Add Blured View
JWBlurView *bluredView = [[JWBlurView alloc] initWithFrame:overlayView.bounds];
bluredView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
bluredView.tag = kENPopUpBluredViewTag;
[bluredView setBlurAlpha:.0f];
[bluredView setAlpha:.0f];
[bluredView setBlurColor:[UIColor clearColor]];
bluredView.backgroundColor = [UIColor clearColor];
[overlayView addSubview:bluredView];
// Make the background clickable
UIButton * dismissButton = [UIButton buttonWithType:UIButtonTypeCustom];
dismissButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
dismissButton.backgroundColor = [UIColor clearColor];
dismissButton.frame = sourceView.bounds;
[overlayView addSubview:dismissButton];
[dismissButton addTarget:self action:#selector(dismissPopUpViewController)
forControlEvents:UIControlEventTouchUpInside];
// Customize popUpView
popUpView.layer.cornerRadius = 3.5f;
popUpView.layer.masksToBounds = YES;
popUpView.layer.zPosition = 99;
popUpView.tag = kENPopUpViewTag;
popUpView.center = overlayView.center;
[popUpView setNeedsLayout];
[popUpView setNeedsDisplay];
[overlayView addSubview:popUpView];
[sourceView addSubview:overlayView];
[self setAnimationStateFrom:popUpView];
[self performAppearAnimationWithBlurView:bluredView popupView:popUpView completion:completionBlock];
}
#pragma mark - Animation
- (void)setAnimationStateFrom:(UIView *)view
{
CALayer *layer = view.layer;
layer.transform = [self transform3d];
}
- (CATransform3D)transform3d
{
CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DTranslate(transform, 0, 200.f, 0);
transform.m34 = 1.0/800.0;
transform = CATransform3DRotate(transform, kRotationAngle*M_PI/180.f, 1.f, .0f, .0f);
CATransform3D scale = CATransform3DMakeScale(.7f, .7f, .7f);
return CATransform3DConcat(transform, scale);
}
- (void)performAppearAnimationWithBlurView:(JWBlurView *)blurView popupView:(UIView *)popupView completion:(void (^)(void))completionBlock
{
CATransform3D transform;
transform = CATransform3DIdentity;
[UIView animateWithDuration:kAnimationDuration
animations:^ {
[self.en_popupViewController viewWillAppear:NO];
[blurView setAlpha:1.f];
popupView.layer.transform = transform;
}
completion:^(BOOL finished) {
[self.en_popupViewController viewDidAppear:NO];
if (completionBlock != nil) {
completionBlock();
}
}];
}
- (void)performDismissAnimationInSourceView:(UIView *)sourceView
withBlurView:(JWBlurView *)blurView
popupView:(UIView *)popupView
overlayView:(UIView *)overlayView
completion:(void (^)(void))completionBlock
{
CATransform3D transform = [self transform3d];
[UIView animateWithDuration:kAnimationDuration
animations:^ {
[self.en_popupViewController viewWillDisappear:NO];
[blurView setAlpha:0.f];
popupView.layer.transform = transform;
}
completion:^(BOOL finished) {
[popupView removeFromSuperview];
[blurView removeFromSuperview];
[overlayView removeFromSuperview];
[self.en_popupViewController viewDidDisappear:NO];
self.en_popupViewController = nil;
if (completionBlock != nil) {
completionBlock();
}
}];
}
#pragma mark - Getters
- (UIView*)topView {
UIViewController *recentView = self;
while (recentView.parentViewController != nil) {
recentView = recentView.parentViewController;
}
return recentView.view;
}
#end
I am beginner in ios.Some one please give some solution for my problem.Thanks in advance !
I changed the code of UIViewController+ENPopUp.m for have a visible button.
In code existe a button with screen size for dismiss view. I changed this button and now he is visible.
In presentPopUpView UIViewController+ENPopUp.m where have this comment " // Make the background clickable" I change the code to this:
CGFloat buttonSize = 10;
UIButton * dismissButton = [[UIButton alloc] init];
dismissButton.backgroundColor = [UIColor redColor];
dismissButton.frame = CGRectMake((self.view.frame.size.width/2) - (buttonSize/2),(self.view.frame.size.height/2) + (self.view.frame.size.height/4) , buttonSize, buttonSize);
[overlayView addSubview:dismissButton];
[dismissButton addTarget:self action:#selector(dismissPopUpViewController)
forControlEvents:UIControlEventTouchUpInside];
This create a red button 10x10 like in figure:
Now, you can change the color and the size of button for what you want.
I hope this can help you.

Subview enlarges when toolbars vanish

I've made a subview to record sound which looks like this:
http://i.stack.imgur.com/EBdEV.png
After the bars faded, it looks like this:
http://i.imgur.com/sDAp4nk.png
I couldn't figure out why. This is the controller. Is there something in the storyboard I could turn on/off?
Thanks for help :)
#import "SubviewController.h"
#implementation SubviewController
#synthesize delegate;
- (void)viewWillAppear:(BOOL)inAnimated {
[super viewWillAppear:inAnimated];
if([self.delegate respondsToSelector:#selector(subviewControllerWillAppear:)]) {
[self.delegate subviewControllerWillAppear:self];
}
}
- (void)viewWillDisappear:(BOOL)inAnimated {
if([self.delegate respondsToSelector:#selector(subviewControllerWillDisappear:)]) {
[self.delegate subviewControllerWillDisappear:self];
}
[super viewWillDisappear:inAnimated];
}
- (void)presentFromViewController:(UIViewController *)inViewController animated:(BOOL)inAnimated {
CGRect theBounds = inViewController.view.bounds;
UIView *theView = self.view;
UIView *theBackgroundView = [[UIView alloc] initWithFrame:theBounds];
CGRect theFrame = theView.frame;
theFrame.origin.x = (CGRectGetWidth(theBounds) - CGRectGetWidth(theFrame)) / 2.0;
theFrame.origin.y = (CGRectGetHeight(theBounds) - CGRectGetHeight(theFrame)) / 2.0;
theView.frame = theFrame;
[inViewController addChildViewController:self];
theBackgroundView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.8];
theBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
theBackgroundView.alpha = 0.0;
[theBackgroundView addSubview:theView];
[inViewController.view addSubview:theBackgroundView];
[UIView animateWithDuration:inAnimated ? 0.75 : 0.0
animations:^{
theBackgroundView.alpha = 1.0;
}
completion:^(BOOL inFinished) {
[self didMoveToParentViewController:inViewController];
}];
}
- (void)dismissAnimated:(BOOL)inAnimated {
UIView *theView = self.view;
UIView *theBackgroundView = theView.superview;
[self willMoveToParentViewController:nil];
[UIView animateWithDuration:inAnimated ? 0.75 : 0.0
animations:^{
theBackgroundView.alpha = 0.0;
}
completion:^(BOOL inFinished) {
[theBackgroundView removeFromSuperview];
[theView removeFromSuperview];
[self removeFromParentViewController];
}];
}
#end
#implementation SubviewSegue
- (void)perform {
[self.destinationViewController presentFromViewController:self.sourceViewController animated:YES];
}
#end
Check your constraints. You probably have one that has a minimum height between 2 subviews and its pushing that toolbar down or something.
Also, a lot of weird things happen when you animate frames while autolayout is on so be careful about that.

How to dealloc a UIView while one of its subviews is animating?

-------->
I am attempting to create a custom UIActivityIndicatorView. The custom view should behave the exactly the same as the standard view, except the image that it spins looks different. I noticed that my custom view would not deallocate when it is removed from its superview in the following test code:
ActivityIndicatorCustomView* v = [[ActivityIndicatorCustomView alloc] initWithFrame:CGRectMake(50.0f, 50.0f, 100.0f, 100.0f)];
[[UIApplication sharedApplication].keyWindow addSubview:v];
[v removeFromSuperview];
The culprit is the animation block, because when it is commented out, dealloc will be called. I believe it is a retain cycle, but I don't see how to solve the issue.
ActivityIndicatorCustomView.h
#import <UIKit/UIKit.h>
#interface ActivityIndicatorCustomView : UIView
#property(nonatomic, assign, readonly) BOOL isAnimating;
- (void)startAnimating;
- (void)stopAnimating;
#end
ActivityIndicatorCustomView.m
static const NSTimeInterval ANIMATION_PERIOD_HALF_LIFE = 1.0f;
#import "ActivityIndicatorCustomView.h"
#interface ActivityIndicatorCustomView ()
#property(nonatomic, strong) UIImageView* imageView;
#property(nonatomic, assign, readwrite) BOOL isAnimating;
- (void)animateWithTransform:(CGAffineTransform)transform;
#end
#implementation ActivityIndicatorCustomView
#pragma mark NSObject
- (void)dealloc
{
NSLog(#"dealloc");
}
#pragma mark UIView
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"activityIndicatorCustom"]];
self.imageView.frame = self.bounds;
[self addSubview:self.imageView];
}
return self;
}
- (void)didMoveToSuperview
{
if (!self.hidden && self.superview != nil) {
[self startAnimating];
}
}
- (void)willMoveToSuperview:(UIView *)newSuperview
{
if (newSuperview == nil) {
[self stopAnimating];
}
}
- (void)setHidden:(BOOL)hidden
{
if (hidden) {
[self stopAnimating];
} else if (self.superview != nil) {
[self startAnimating];
}
[super setHidden:hidden];
}
#pragma mark ActivityIndicatorCustomView
- (void)startAnimating
{
if (self.isAnimating) {
return;
}
self.isAnimating = YES;
[self animateWithTransform:CGAffineTransformMakeRotation((CGFloat)M_PI)];
}
- (void)stopAnimating
{
[self.imageView.layer removeAllAnimations];
self.isAnimating = NO;
}
#pragma mark ()
- (void)animateWithTransform:(CGAffineTransform)transform
{
// Must split the animation into two semi-circles. If
// you attempt to rotate a full circle, nothing will
// happen.
__block ActivityIndicatorCustomView* weakSelf = self;
[UIView
animateWithDuration:ANIMATION_PERIOD_HALF_LIFE
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
weakSelf.imageView.transform = transform;
} completion:^(BOOL finished) {
[weakSelf animateWithTransform:CGAffineTransformIsIdentity(transform)
? CGAffineTransformMakeRotation((CGFloat)M_PI)
: CGAffineTransformIdentity
];
}
];
}
#end
I was following a bad tutorial on retain cycles in blocks. It told me to do
__block MyViewController *weakSelf = self;
This is wrong. To create a weak reference, I should do this instead:
__weak ActivityIndicatorCustomView* weakSelf = self;
[UIView
animateWithDuration:ANIMATION_PERIOD_HALF_LIFE
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
weakSelf.imageView.transform = transform;
} completion:^(BOOL finished) {
[weakSelf animateWithTransform:CGAffineTransformIsIdentity(transform)
? CGAffineTransformMakeRotation((CGFloat)M_PI)
: CGAffineTransformIdentity
];
}
];
I think this is because you continue animating (and retain self in next [self animateWithTransform:] call) in the completion block. Try, for example, checking for the superview to decide whether to continue animating:
completion:^(BOOL finished) {
if (self.superview) {
[self animateWithTransform:CGAffineTransformIsIdentity(transform)
? CGAffineTransformMakeRotation((CGFloat)M_PI)
: CGAffineTransformIdentity
];
}
}

Second touch animation

Trying to get to grips with Xcode and seem to be making some progress over the last few weeks.
Does anyone know a way that a custom button can do a different set of animations on a second click.
So let say I have a custom button and its of Mario, when i click it he runs from the middle of the screen and out of the right hand side of the screen and then runs back in to the middle from the left of the screen, he also makes noise.
I have achieved this using this code:
- (IBAction)marioRunning_clicked:(id)sender
{
[UIView animateWithDuration:1.50 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
marioRunning.center = CGPointMake(350.5, 456.0);
} completion:^(BOOL finished) {
if (finished) {
[UIView animateWithDuration:0.00 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
marioRunning.center = CGPointMake(-30.5, 456.0);
} completion:^(BOOL finished) {
if (finished) {
[UIView animateWithDuration:1.50 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
marioRunning.center = CGPointMake(160.0, 456.0);
} completion:^(BOOL finished) {
if(finished) // NSLog ( #"Finished !!!!!" );
marioRunning.center = CGPointMake(160.0, 456.0);
}];
}
}];
}
}];
marioRunning.imageView.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:#"mario-running2"],[UIImage imageNamed:#"mario-running3"],nil];
marioRunning.imageView.animationDuration = 0.15;
marioRunning.imageView.animationRepeatCount = 19;
[marioRunning.imageView startAnimating];
}
How could I make him do a second set of animations on the next click? For example instead of running from left to right, if i tap him the second time he will Jump up and down?
Use the selected state of the button to decide which animation to do
-(void)buttonClicked:(UIButton*)button
{
if(button.selected)
{
[self doAnimation1];
}
else
{
[self doAnimation2];
}
button.selected = !button.selected;
}
This might be overkill, but here's a cool way to do what you want:
Make a subclass of UIButton, and let's call it DDDMarioButton:
typedef void (^DDDAnimationBlock)(UIButton *button);
#interface DDDMarioButton : UIButton
- (void)addAnimationBlockToQueue:(DDDAnimationBlock)block;
#end
Then in DDDMarioButton.m:
#interface DDDMarioButton ()
#property (nonatomic, strong) NSMutableArray *animationQueue;
#end
#implementation DDDMarioButton
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self addTarget:self action:#selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
}
return self;
}
- (void)buttonPressed:(id)button
{
DDDAnimationBlock block = self.animationQueue[0];
block(self);
[self.animationQueue removeObjectAtIndex:0];
}
- (void)addAnimationBlockToQueue:(DDDAnimationBlock)block
{
if(!self.animationQueue)
{
self.animationQueue = [NSMutableArray new];
}
[self.animationQueue addObject:block];
}
#end
and then wherever you create your buttons, you add each step one by one:
DDDMarioButton *button = [[DDDMarioButton alloc] initWithFrame:CGRectZero];
[button addAnimationBlockToQueue:^(UIButton *button) {
// perform some animation
}];
[button addAnimationBlockToQueue:^(UIButton *button) {
// perform another animation
}];
And that should do it. I haven't tested this, you'll probably need some configuration, but that's pretty much the idea.

app crashing in doing slide menu in ios

I am doing slide menu like Facebook in iOS a simple app I where doing step by step process from tutorial which available in this link http://www.raywenderlich.com/32054/how-to-create-a-slide-out-navigation-like-facebook-and-path
. I am only doing right panel slide when I click button it moving slide happening but when I call my main view again it is happening but app getting crash could any one help me to get out from this problem
#define RIGHT_PANEL 2
#define CENTRAL_TAG 1
#define SLIDE_TIMING .25
#define PANEL_WIDTH 60
#interface MainViewController ()<CenterViewControllerDelegate>
#property(nonatomic,strong)CentralViewController *centralView;
#property(nonatomic,strong)RightViewController *RightView;
#property (nonatomic, assign) BOOL showingRightPanel;
-(UIView*)getright;
-(UIView*)resetmainView;
#end
#implementation MainViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.centralView = [[CentralViewController alloc] initWithNibName:#"CentralViewController" bundle:nil];
self.centralView.view.tag = CENTRAL_TAG;
self.centralView.delegate=self;
[self.view addSubview:self.centralView.view];
[self addChildViewController:_centralView];
[_centralView didMoveToParentViewController:self];
}
-(UIView*)getright
{
if(_RightView==Nil)
{
self.RightView=[[RightViewController alloc]initWithNibName:#"RightViewController" bundle:Nil];
self.RightView.view.tag=RIGHT_PANEL;
self.RightView.delegate=self;
[self.view addSubview:self.RightView.view];
[self addChildViewController:self.RightView];
[_RightView didMoveToParentViewController:self];
_RightView.view.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}
self.showingRightPanel=YES;
UIView *view=self.RightView.view;
return view;
}
-(void)MovetoOriginal
{
[UIView animateWithDuration:SLIDE_TIMING delay:0 options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
_centralView.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}
completion:^(BOOL finished) {
if (finished) {
[self resetmainView];
}
}];}
-(void)rightpanelmove
{
UIView *child=[self getright];
[self.view sendSubviewToBack:child];
[UIView animateWithDuration:SLIDE_TIMING delay:0 options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
_centralView.view.frame = CGRectMake(-self.view.frame.size.width + PANEL_WIDTH, 0, self.view.frame.size.width, self.view.frame.size.height);
}
completion:^(BOOL finished) {
if (finished) {
_centralView.rightbutton.tag = 1;
}
}];
}
-(UIView*)resetmainView
{
if(_RightView!=Nil)
{
[self.RightView.view removeFromSuperview];
self.RightView=Nil;
_centralView.rightbutton.tag=0;
self.showingRightPanel=NO;
}
This is my main control code where am calling the event
And this one is button action code
- (IBAction)btnright:(id)sender {
UIButton *button = sender;
switch (button.tag) {
case 0: {
[_delegate rightpanelmove];
break;
}
case 1: {
[_delegate MovetoOriginal];
break;
}
default:
break;
}}
-(UIView*)resetmainView
{
if(_RightView!=Nil)
{
[self.RightView.view removeFromSuperview];
self.RightView=Nil;
_centralView.rightbutton.tag=0;
self.showingRightPanel=NO;
}
UIView *view=self.centralView.view;
return view;
}
This what i missed now it is working!!!!

Resources