我正在尝试使用下面的代码在 ECSlidingViewController(a UITableVIEW) 中填充菜单,但是当我运行应用程序时,菜单或 uitableview 是空白的,并且没有填充 3 个 MenuItem;重要、邀请和议程。我怀疑问题出在 didSelectRowAtIndexPath 中,但我不确定。对此的任何帮助将不胜感激。谢谢你。
#import "MenuViewController.h"
@interface MenuViewController ()
@property (nonatomic, strong) NSArray *menuItems;
@end
@implementation MenuViewController
@synthesize menuItems;
- (void)awakeFromNib
{
self.menuItems = [NSArray arrayWithObjects:@"Important", @"Invitation", @"Agenda", nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.slidingViewController setAnchorRightRevealAmount:280.0f];
self.slidingViewController.underLeftWidthLayout = ECFullWidth;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
{
return self.menuItems.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"MenuItemCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = [self.menuItems objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = [NSString stringWithFormat:@"%@", [self.menuItems objectAtIndex:indexPath.row]];
UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:identifier];
[self.slidingViewController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
CGRect frame = self.slidingViewController.topViewController.view.frame;
self.slidingViewController.topViewController = newTopViewController;
self.slidingViewController.topViewController.view.frame = frame;
[self.slidingViewController resetTopView];
}];
}