0

I'd like to make MenuView display with animation.

When I call -showSideMenu, MenuView does not appear.

How do I fix it?

MenuView.h

#import <UIKit/UIKit.h>

@interface SettingView : UIView

@end

MenuView.m

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.frame = CGRectMake(320, 0, 240, 568);
        self.backgroundColor = [UIColor turquoiseColor];
    }
    return self;
}

MasterViewController.m

@property (nonatomic, strong) MenuView* sideMenuView;

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIBarButtonItem* menuButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showSideMenu:)];
    self.navigationItem.rightBarButtonItem = menuButton;

    self.sideMenuView = [[MenuView alloc]initWithFrame:self.view.frame];
    [self.view addSubview:self.sideMenuView];
}

- (IBAction)showSideMenu:(id)sender
{
    [UIView animateWithDuration:0.3f
                          delay:0.0f
                        options:UIViewAnimationOptionCurveEaseIn
                     animations:^{
                         self.sideMenuView.frame = CGRectMake(80, 0, 240, 568);
                     }
                     completion:^(BOOL finished) {
                     }];
}
MasterAM
  • 16,283
  • 6
  • 45
  • 66
kusumoto_teruya
  • 2,415
  • 4
  • 23
  • 38

1 Answers1

0

Couple of things:

  • Put an NSLog in the showSideMenu method. Does it actually fire?
  • You animate the frame. Do you have AutoLayout turned off for this view controller?
Kumar KL
  • 15,315
  • 9
  • 38
  • 60
Bart van Kuik
  • 4,704
  • 1
  • 33
  • 57