問題: 使用MainStoryBoard定義Cell 使用後顯示空白Cell,定義的視圖沒有顯示.
解答: 使用慣了xib定義的cell 之後在viewdidload 中習慣性的註冊cell,在storyBoard中不需要註冊(不需要代碼註冊)只需要在方法
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
中添加
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableViewCell"];
原因是在MainstoryBoard中 我們已經對自定義的Cell 進行了註冊
如圖,我們在Cell的屬性界面對其進行了註冊,identifier 爲"TableViewCell"
不需要在 ViewDidLoad 對其進行註冊了,如果進行註冊的話,則對xcode來說你引用的不是storyboard上的定義的Cel,而是你創建的空Cell類了,所以顯示爲空白.