giridharvc7 / VCFloatingActionButton

A Floating Action Button just like Google inbox for iOS
MIT License
296 stars 77 forks source link

Action buttons move up when the add/plus button is clicked #8

Open xarlotie opened 8 years ago

xarlotie commented 8 years ago

I use the action buttons on a scrollview but when i click the plus button, all sub-buttons appear but they are translated upward. What might be causing this? Thanks!

giridharvc7 commented 8 years ago

Can you post a screenshot ?

xarlotie commented 8 years ago

ios simulator screen shot jul 23 2015 2 59 40 pm ios simulator screen shot jul 23 2015 2 59 44 pm

xarlotie commented 8 years ago

Even when i dont add the "Related Content" button and Ad view at the bottom, the flaoting action buttons still move.

ios simulator screen shot jul 23 2015 3 07 58 pm ios simulator screen shot jul 23 2015 3 08 01 pm

giridharvc7 commented 8 years ago

Ok, let me check, are you using swift ? Cos i havent tested it out in swift

xarlotie commented 8 years ago

I'm using Objective-C. And the value for withScrollView is a webview's scrollview.

withScrollview:self.webView.scrollView
xarlotie commented 8 years ago

Hi @gizmoboy7! Any update on this? Thanks!

telmopmota commented 8 years ago

Got the same issue after changed UINavigationBar backgroundImage. Add below code and issue happens:

UINavigationBar *navBar = [[self navigationController] navigationBar];
UIImage *backgroundImage = [UIImage imageNamed:@"MyNavigationBarBackground"];
[navBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
haroldogtf commented 8 years ago

I could fix this issue in my project using:

In My ViewController.m I remove the NavigationBar and StatusBar height size.

CGRect frame = CGRectMake(size.width - FAB_SIZE - MARGIN,
                          size.height - FAB_SIZE - MARGIN - navBarHeight - statusBarHeight,
                          FAB_SIZE,
                          FAB_SIZE);

I defined a new method in the VCFloatingActionButton.h

-(id)initWithFrame:(CGRect)frame 
       normalImage:(UIImage*)passiveImage 
   andPressedImage:(UIImage*)activeImage
    withScrollview:(UIScrollView*)scrView 
  andNavigationBar:(UINavigationBar*)navBar;

and Here the implementation of the new Method in VCFloatingActionButton.m

-(id)initWithFrame:(CGRect)frame 
       normalImage:(UIImage*)passiveImage 
   andPressedImage:(UIImage*)activeImage
    withScrollview:(UIScrollView*)scrView 
  andNavigationBar:(UINavigationBar*)navBar {

  self = [self initWithFrame:frame normalImage: passiveImage andPressedImage:activeImage withScrollview:scrView];

  if(navBar) {
      int statusBar = [UIApplication sharedApplication].statusBarFrame.size.height;

      _buttonView.frame = CGRectMake(frame.origin.x,
                                     frame.origin.y + navBar.frame.size.height + statusBar,
                                     frame.size.width,
                                     frame.size.height);

      _menuTable.frame = CGRectMake(SCREEN_WIDTH/4,
                                    0,
                                    0.75*SCREEN_WIDTH,
                                    SCREEN_HEIGHT - (SCREEN_HEIGHT - CGRectGetMaxY(self.frame) - navBar.frame.size.height - statusBar));
    }
    return self;
}