单击后,侧面菜单项完全空白

时间:2017-06-24 09:00:54

标签: ios navbar side-menu

打开侧边菜单后,每当我点击任何一个项目时,侧边菜单都会变成空白,只显示白色屏幕。

我该如何解决这个问题?

viewCotroller文件:

enum TranslateDirection {
    LEFT, RIGHT
};

const float TRANSLATE_CONST = 250;
float translateX = TRANSLATE_CONST;
enum TranslateDirection td = RIGHT;
bool flag = 0;


- (void)viewDidLoad {
    [super viewDidLoad];
    NavViewController *view;

    view = [self.storyboard instantiateViewControllerWithIdentifier:@"navigationView"];
    [self.navigationController.view.window insertSubview:view.view atIndex:0];


    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)showMenu:(id)sender {

    [UIView animateWithDuration:0.5f

                          delay:0.02

                        options:UIViewAnimationOptionCurveEaseIn

                     animations:^{
                         if (td == LEFT) {
                             translateX = 0;
                         } else if (td == RIGHT) {
                             translateX = TRANSLATE_CONST;
                         }

                         CGAffineTransform trans = CGAffineTransformMakeTranslation(translateX, 0);

                         self.navigationController.view.transform = trans;

                     }

                     completion:^(BOOL finished){

                         if (td == LEFT) {
                             td = RIGHT;
                         } else if (td == RIGHT) {
                             td = LEFT;
                         }

                     }
          ];
    /*if (flag == 0) {
        [_showMenubar setStyle:UIBarButtonSystemItemAdd];
        flag = 1;
    } else {
        flag = 0;
    }*/

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)menu:(id)sender {
}
@end

sideMenuFile代码:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //_navItems = [[NSMutableArray alloc] initWithObjects:@"abc", @"abc", @"abc", nil];
    _navItems = [NSArray arrayWithObjects:@"Inbox", @"* Important and unread", @"* Starred", @"* Everything", @"Sent Mail", @"Drafts", @"Spam" ,nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return @"Hello";
}

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
    return @" bye";
}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_navItems count];
}

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleIdentifier];
    }

    // Configure the cell...
    /*cell.textLabel.font = [UIFont fontWithName:@"Sans Serif" size:12];
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.backgroundColor = [UIColor clearColor];*/

    cell.textLabel.text = [_navItems objectAtIndex:indexPath.row];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

}

0 个答案:

没有答案