1

打开侧边菜单后,每当我点击它的任何项目时,侧边菜单都会完全空白,只显示一个白屏。

我该如何解决这个问题?

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

sideMenu文件代码:

- (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 {

}
4

0 回答 0