Ios 从侧面菜单中选择主视图控制器
我正在开发一个可以在上找到的应用程序,但我不知道如何使用滑动侧菜单。其想法是主ViewController将更改为在侧菜单中选择的不同视图(不带后退箭头),然后将主ViewController滑回。我可以让ViewController滑动,但我不能让segue正确。当按下侧菜单中的“日历”按钮时,我正在尝试从“ViewController.m”切换到“CalendarView.XIB” ViewController.m:Ios 从侧面菜单中选择主视图控制器,ios,objective-c,uiviewcontroller,ios8,uistoryboardsegue,Ios,Objective C,Uiviewcontroller,Ios8,Uistoryboardsegue,我正在开发一个可以在上找到的应用程序,但我不知道如何使用滑动侧菜单。其想法是主ViewController将更改为在侧菜单中选择的不同视图(不带后退箭头),然后将主ViewController滑回。我可以让ViewController滑动,但我不能让segue正确。当按下侧菜单中的“日历”按钮时,我正在尝试从“ViewController.m”切换到“CalendarView.XIB” ViewController.m: -(void)tableView:(UITableView *)table
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
NSLog(@"Pressed 0");
BlogView *blogView = [[BlogView alloc] init];
[self.puView addSubview:blogView];
[self hideMenu];
}
else if (indexPath.row == 1) {
NSLog(@"Pressed 1");
TwitterView *twitView = [[TwitterView alloc] init];
[self hideMenu];
[self.puView addSubview:twitView];
}
else if (indexPath.row == 2) {
NSLog(@"Pressed 2");
PowerView *pschoolView = [[PowerView alloc] init];
[self hideMenu];
[self.puView addSubview:pschoolView];
}
else if (indexPath.row == 3) {
NSLog(@"Pressed 3");
CalendarView *calView = [[CalendarView alloc] init];
[self.puView addSubview:calView];
[self hideMenu];
}
else {
NSLog(@"Error");
//ErrorView *errorV = [[ErrorView alloc] init];
//[self hideMenu];
//[self.puView addSubview:errorV];
}
}
如果您使用故事板控件,请手动创建片段并设置标识符,然后使用
[self performSegueWithIdentifier:@"IDENTIFIER" sender:nil];
我能想到的最好结果是:)您还没有加载nib,下面是一个日历示例:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"CalendarView" owner:self options:nil];
if (indexPath.row == 0) {
....
}
else if (indexPath.row == 3) {
NSLog(@"Pressed 3");
CalendarView *calView = [subviewArray objectAtIndex:0];
[self.puView addSubview:calView];
[self hideMenu];
}
else {
NSLog(@"Error");
}
}
因此,对每个菜单项执行相同的操作