2014-09-24 26 views
-1

我有一個自定義單元格中,實現代碼如下是當我不使用此方法的工作原理:的UIView在CustomCell將爲零後,我的RegisterClass

self.tableView.registerClass(goodsCell.self, forCellReuseIdentifier: "gCell"); 

但在那之後我用,上述方法,一些錯誤發生。

全部UIView在自定義單元格中像UILabel ...等變成零,所以我不能使用它。

我的自定義單元格是在StoryBoard

誰能告訴我如何解決它?


編輯:

我真的問傻QUZ ... 我去了這個代碼到B的ViewController:

var page = BViewController(); 
self.presentViewController(page, animated: true, completion: nil); 

其實...查看此頁面是empty..because它的視圖是由故事板創建的。 所以,我改變了這樣的代碼:

var page = self.storyboard?.instantiateViewControllerWithIdentifier("bViewController") as bViewController; 
self.presentViewController(page, animated: true, completion: nil); 

這個代碼將故事板視圖得到,那麼你的觀點不是空的了。 但它必須在故事板中設置ViewController的idnetifier,否則會得到錯誤消息。

希望以前像我這樣的人會看到這個。

回答

1

現在我發現自己的答案,因爲我真的不加載佈局 我用這個方法去到另一個頁面:

self.navigationController?.pushViewController(next, animated: true); 

然後,這樣讓我沒有加載ViewController。所以我找不到這個細胞是正常的。

finnally我用下面的代碼來解決的ViewController沒裝:

var next = self.storyboard.instantiateViewControllerWithIdentifier("view1") as page; 
self.navigationController?.pushViewController(next, animated: true); 

我不知道這樣是好還是壞,但它的工作。

-2

嘗試

self.tableView.registerClass(goodsCell.self, forCellReuseIdentifier: @"gCell"); 

缺少一個「@」

+0

此代碼位於Swift中,在字符串之前不再有'@' – Alfonso 2014-09-24 12:01:21

+0

這些標籤只是ios和自定義單元格。我的錯 – latenitecoder 2014-09-24 14:14:41

相關問題