我正在使用本教程介紹如何創建彈出式菜單。 http://www.appcoda.com/ios-programming-sidebar-navigation-menu/我的表格視圖無法填充
我在閱讀教程時瞭解了它,現在我正試圖將它實現到我的應用程序中。
我在我可以按菜單按鈕並彈出菜單出現的階段。問題是,它不會填充我的表格視圖單元格。
我爲每個表視圖單元格設置標識符,然後在代碼中將它們引用爲完整的數組。
我知道在教程中如何在定義數組中的內容時拼寫其中的一個標識符時,程序會崩潰。在我的應用程序中,情況並非如此。希望這可以幫助確定問題。它甚至不會改變代碼的第一部分的顏色。
這是代碼。
#import "SidebarViewController.h"
#import "SWRevealViewController.h"
@interface SidebarViewController()
@property (nonatomic, strong) NSArray *menuItems;
@end
@implementation SidebarViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithWhite:0.2f alpha:1.0f];
self.tableView.backgroundColor = [UIColor colorWithWhite:0.2f alpha:1.0f];
self.tableView.separatorColor = [UIColor colorWithWhite:0.15f alpha:0.2f];
_menuItems = @[@"markup",@"tax"];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [self.menuItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
return cell;
}
任何幫助將是偉大的。
感謝
即使應該執行的第一段代碼應該改變顏色,使其非常黑暗(這在我的教程文件中有效),但我認爲代碼和對象之間的連接存在問題。我已經檢查了連接檢查器,並且我的當前項目與我的教程文件具有完全相同的連接。 – user1923975
可能聽起來像一個愚蠢的問題,但你檢查你的表視圖控制器對象的類? – Yazid