How prevent view under navbar in iMessage app extension
Asked Answered
R

2

0

I have the same issue in this post, i follow all recommended in that answers but notting works, in my case the difference is that i have a table view controller.

I have tried in many ways to prevent this from happening.

example:

-(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;
}

Inside viewDidLoad:

    self.navigationController.navigationBar.translucent = NO;

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

This is my UITableViewController config:

enter image description here

This is exactly my problem:

enter image description here

Thanks for help.

Riviera answered 17/1, 2017 at 21:17 Comment(4)
Have you tried 'Under Top Bars'?Compliment
@TheValyreanGroup, yes in my screenshot is disable. Should be enable? That makes sense?Riviera
Well, you want it to be 'UNDER' the top bar, so yes, i would think that might help.Compliment
@Compliment not works. same resultRiviera
C
0

Have you tried with disabling under navigation bar appearance in your view controller? Put following in your init:

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

I've used Masonry AutoLayout library for setting up constraints and following snippet worked:

[_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;
Could answered 19/1, 2017 at 8:40 Comment(0)
L
0

You can use constraints to the view.

Set a top View constraint for the compact view like:

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

Update your constraint on compact and expanded view in 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;
  }
}
Lowry answered 1/2, 2017 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.