2015-11-04 3 views
0

Я использовал MFSideMenu для отображения моих пунктов меню. Но я не знаю, почему он показывает мне черную линию в конце.Удалить черный цвет с MFSideMenuController (правая сторона)

Как удалить черную часть.

Вот изображение, что появляется в конце

enter image description here

я использовал https://github.com/mikefrederick/MFSideMenu интегрировать MFSideMenu.

Это мой код для Sidemen

-(void) viewDidLoad 
{ 
[super viewDidLoad]; 

self.view.backgroundColor = CustomPinkColor; 
MenuArray =[NSArray arrayWithObjects:@"Knects",@"Settings",@"Share",@"About",nil]; 
//tableView.backgroundColor = CustomPinkColor; 
tableView.alwaysBounceVertical = NO; 
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; 

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section 
{ 
return MenuArray.count; 
    } 

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    cell.backgroundColor=CustomPinkColor; 
    cell.textLabel.textColor=[UIColor blackColor]; 
} 
cell.textLabel.text = [MenuArray objectAtIndex:indexPath.row]; 
return cell; 
    } 

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
return 40; 
} 

    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 
    { 
UIView *colorView = [[UIView alloc]init]; 
colorView.backgroundColor = CustomPinkColor; 
return colorView; 
    } 

ответ

2

это autolayout вопрос таким образом, вы можете исправить это:

Шаг 1: Добавить этот метод MFSideMenuContainerViewController контроллер

- (void)layoutContraintsforLeftView:(UIView*)view adjestToContainer:(UIView*)container { 
    if(!view) { 
     return; 
    } 

    view.translatesAutoresizingMaskIntoConstraints = NO; 

    [container addConstraint:[NSLayoutConstraint constraintWithItem:view 
                  attribute:NSLayoutAttributeTop 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:container 
                  attribute:NSLayoutAttributeTop 
                 multiplier:1.0 
                  constant:0.0]]; 

    [container addConstraint:[NSLayoutConstraint constraintWithItem:view 
                  attribute:NSLayoutAttributeLeading 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:container 
                  attribute:NSLayoutAttributeLeading 
                 multiplier:1.0 
                  constant:0.0]]; 

    [container addConstraint:[NSLayoutConstraint constraintWithItem:view 
                  attribute:NSLayoutAttributeTrailing 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:container 
                  attribute:NSLayoutAttributeTrailing 
                 multiplier:1.0 
                  constant:0]]; 

    [container addConstraint:[NSLayoutConstraint constraintWithItem:view 
                  attribute:NSLayoutAttributeBottom 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:container 
                  attribute:NSLayoutAttributeBottom 
                 multiplier:1.0 
                  constant:0.0]]; 
    [view layoutIfNeeded]; 
} 



- (void)layoutContraintsForRightView:(UIView*)view adjestToContainer:(UIView*)container { 
    if(!view) { 
     return; 
    } 

    view.translatesAutoresizingMaskIntoConstraints = NO; 

    [container addConstraint:[NSLayoutConstraint constraintWithItem:view 
                  attribute:NSLayoutAttributeTop 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:container 
                  attribute:NSLayoutAttributeTop 
                 multiplier:1.0 
                  constant:0.0]]; 

    [container addConstraint:[NSLayoutConstraint constraintWithItem:view 
                  attribute:NSLayoutAttributeLeading 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:container 
                  attribute:NSLayoutAttributeLeading 
                 multiplier:1.0 
                  constant:50.0]]; 

    [container addConstraint:[NSLayoutConstraint constraintWithItem:view 
                  attribute:NSLayoutAttributeTrailing 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:container 
                  attribute:NSLayoutAttributeTrailing 
                 multiplier:1.0 
                  constant:0.0]]; 

    [container addConstraint:[NSLayoutConstraint constraintWithItem:view 
                  attribute:NSLayoutAttributeBottom 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:container 
                  attribute:NSLayoutAttributeBottom 
                 multiplier:1.0 
                  constant:0.0]]; 
    [view layoutIfNeeded]; 
} 

Шаг 2: Заменить метод - (void)setupMenuContainerView) с этим

- (void)setupMenuContainerView { 
    if(self.menuContainerView.superview) return; 

    self.menuContainerView.frame = self.view.bounds; 
    self.menuContainerView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 

    [self.view insertSubview:menuContainerView atIndex:0]; 
    [self layoutContraintsforLeftView:menuContainerView adjestToContainer:self.view]; 


    if(self.leftMenuViewController && !self.leftMenuViewController.view.superview) { 
     [self.menuContainerView addSubview:self.leftMenuViewController.view]; 
     [self layoutContraintsforLeftView:self.leftMenuViewController.view adjestToContainer:menuContainerView]; 
    } 

    if(self.rightMenuViewController && !self.rightMenuViewController.view.superview) { 
     [self.menuContainerView addSubview:self.rightMenuViewController.view]; 
     [self layoutContraintsForRightView:self.rightMenuViewController.view adjestToContainer:menuContainerView]; 
    } 
} 

Шаг 3: Теперь сделал .. запустить свой код. . Счастливое Кодирование :) enter image description here

enter image description here

+0

Это работает, но мой список теперь не виден @Sachin –

+0

я испытал в этом кодовой https://github.com/mikefrederick/MFSideMenu. Он работает там. – SachinVsSachin

+0

Вы используете автозапуск в режиме просмотра списка? – SachinVsSachin

Смежные вопросы