如何防止在iMessage应用程序扩展中的导航栏下的视图
问题描述:
我在this post我有同样的问题,我遵循所有建议的答案,但没有工作,在我的情况不同的是,我有一个表视图控制器。如何防止在iMessage应用程序扩展中的导航栏下的视图
我试过很多方法来防止这种情况发生。
例如:
-(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
配置:
这也正是我的问题:
感谢您的帮助。
答
您是否尝试过在导航栏外观下在视图控制器中禁用? 把你的init以下:
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
我用Masonry自动版式库建立约束和下面的代码片段工作:
[_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;
答
您可以使用约束的观点。
设置的顶视图约束对于喜欢紧凑的观点:
@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;
}
}
你试过“在热门酒吧”? – TheValyreanGroup
@TheValyreanGroup,在我的屏幕截图是禁用。应该启用?这就说得通了? – jose920405
嗯,你想让它成为'*酒吧',所以是的,我认为这可能会有所帮助。 – TheValyreanGroup