【问题标题】:Floating Button Animation Doesn't Work In UITableViewController浮动按钮动画在 UITableViewController 中不起作用
【发布时间】:2015-12-07 00:15:21
【问题描述】:

请帮助我了解浮动按钮动画在 UITableViewController 中无法正常工作。下面我附上了视频和代码以便更好地理解,我使用这个库作为浮动按钮https://github.com/gizmoboy7/VCFloatingActionButton

视频: https://youtu.be/m-ivFXjXLOM

代码:

CGRect floatButtonFrame = CGRectMake([UIScreen mainScreen].bounds.size.width - 44 - 20, [UIScreen mainScreen].bounds.size.height - 44 - 20, 44, 44);


    floatingButton = [[VCFloatingActionButton alloc] initWithFrame:floatButtonFrame normalImage:[UIImage imageNamed:@"plus"] andPressedImage:[UIImage imageNamed:@"cross"] withScrollview:self.aktivitiTableView];

    floatingButton.imageArray = @[@"fb-icon",@"twitter-icon",@"google-icon",@"linkedin-icon"];
    floatingButton.labelArray = @[@"Facebook",@"Twitter",@"Google Plus",@"Linked in"];

    floatingButton.hideWhileScrolling = NO;
    floatingButton.delegate = self;

    [self.aktivitiTableView addSubview:floatingButton];

提前谢谢你。

【问题讨论】:

    标签: ios objective-c uitableview


    【解决方案1】:

    您已将按钮添加到 UITableView
    UITableViewUIScrollView 子类,因此通过这样做,您实际上已将按钮添加到滚动视图边界中,因此当您滚动表格视图时它会移动(更改 contentOffset)。

    相反,您希望将其添加到表视图的超级视图中,但是如果您实际使用的是UITableViewController,那么self.view == self.tableView。您可以将其添加到self.tableView.superview,但它超出了您的视图控制器范围,因此我不建议您这样做。

    您要么想从包含的视图控制器实现中添加它(如果您可以访问它),将UITableViewController 嵌入父级UIViewController 或将您的视图控制器实现更改为UIViewController 的子类,然后添加表格视图作为 self.view 自己的子视图。

    无论如何,这都是正确的做事方式。

    【讨论】:

      猜你喜欢
      • 2015-03-11
      • 1970-01-01
      • 1970-01-01
      • 2015-11-08
      • 1970-01-01
      • 2021-07-30
      • 1970-01-01
      • 2016-03-21
      • 1970-01-01
      相关资源
      最近更新 更多