0

我在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配置:

enter image description here

這也正是我的問題:

enter image description here

感謝您的幫助。

+0

你試過「在熱門酒吧」? – TheValyreanGroup

+0

@TheValyreanGroup,在我的屏幕截圖是禁用。應該啓用?這就說得通了? – jose920405

+0

嗯,你想讓它成爲'頂級酒吧',所以是的,我認爲這可能會有所幫助。 – TheValyreanGroup

回答

0

您是否嘗試過在導航欄外觀下在視圖控制器中禁用? 把你的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; 
0

您可以使用約束的觀點。

設置的頂視圖約束對於喜歡緊湊的觀點:

@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; 
    } 
} 
相關問題