【问题标题】:How prevent view under navbar in iMessage app extension如何防止在 iMessage 应用程序扩展中的导航栏下查看
【发布时间】:2017-06-02 02:35:19
【问题描述】:

我在this post 中遇到了同样的问题,我遵循了该答案中的所有建议,但没有奏效,就我而言,区别在于我有一个表格视图控制器。

我已经尝试了很多方法来防止这种情况发生。

示例:

-(void)viewDidLayoutSubviews {

    //the next 2 lines was tested with self.tableView and self.view
    [self.view.topAnchor constraintEqualToAnchor:self.topLayoutGuide.bottomAnchor constant:8.0].active = YES;
    [self.view constraintEqualToAnchor:[self.topLayoutGuide bottomAnchor]].active = YES;

    [self.tableView setContentInset:UIEdgeInsetsMake(self.topLayoutGuide.length, 0, 0, 0)];

    self.automaticallyAdjustsScrollViewInsets = YES;
}

内部viewDidLoad

    self.navigationController.navigationBar.translucent = NO;

    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
        self.edgesForExtendedLayout = UIRectEdgeNone;

这是我的UITableViewController 配置:

这正是我的问题:

感谢您的帮助。

【问题讨论】:

  • 你试过'Under Top Bars'吗?
  • @TheValyreanGroup,是的,在我的屏幕截图中已禁用。应该启用吗?有道理吗?
  • 好吧,您希望它位于顶部栏的“下方”,所以是的,我认为这可能会有所帮助。
  • @TheValyreanGroup 不起作用。结果相同

标签: ios objective-c ios-app-extension imessage imessage-extension


【解决方案1】:

您可以对视图使用约束。

为紧凑视图设置顶部视图约束,例如:

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *searchViewTopConstraints;

在 presentRecentsViewControllerFor 中更新您对紧凑和扩展视图的约束:

-(void)presentRecentsViewControllerFor:(MSConversation*)conversation withPresentStyle:(MSMessagesAppPresentationStyle)presentationStyle
{
  tableViewC = [[UIStoryboard storyboardWithName:@"MainInterface" bundle:nil] instantiateViewControllerWithIdentifier:@"ShareRecents"];
  if (presentationStyle == MSMessagesAppPresentationStyleCompact) {
     NSLog(@"Compact view");
     tableViewC.searchViewTopConstraints.constant = 0;         
  } else
  {
    NSLog(@"Expanded view");
    [self.view.topAnchor constraintEqualToAnchor:[self.topLayoutGuide bottomAnchor]].active = YES;
  }
}

【讨论】:

    【解决方案2】:

    您是否尝试过在视图控制器中禁用导航栏下的外观? 在你的初始化中加入以下内容:

    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
    

    我使用Masonry AutoLayout 库来设置约束并遵循 sn-p 工作:

    [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
    
        make.left.equalTo(self.view.mas_left);
        make.top.equalTo(self.view.mas_top);
        make.right.equalTo(self.view.mas_right);
    }];
    [_collectionView.bottomAnchor constraintEqualToAnchor:[self.bottomLayoutGuide bottomAnchor]].active = YES;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-19
      • 1970-01-01
      • 2017-02-24
      • 2018-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多