2012-05-24 145 views
0

我想初始化一個tableview,其中存儲了一個NSMutableArray中的每個用戶的圖像,名稱和姓氏。 在這個mutablearray我救,我創建用於存儲用戶數據的類,它的模式如下:如何在表格視圖中顯示來自NSMutablearray的數據

ResultSearchController{ 
    NSInteger *userID; 
    NSString *userName; 
    NSString *userSurname; 
    NSString *userThumb; 
} 

我已閱讀TableView中的文檔,但我仍然有疑慮和問題,以顯示TableView中的數據(似乎使用這樣的對象相當複雜)。你能幫我開始嗎? 謝謝!

+0

寫一些'cellForRowAtIndexPath'代碼... –

+1

同意。您需要查看委託和數據源方法。這允許您依次修改每個單元格。如果您使用單元格的行作爲您的NSMutableArray索引,然後編寫修改代碼。它應該修改每個單元格,因爲表格視圖需要它。 – geminiCoder

+3

請看[this](http://adeem.me/blog/2009/05/29/iphone-sdk-tutorial-add-delete-reorder-uitableview-row/)和[this](http:// www .mobisoftinfotech.com/blog/iphone/introduction-to-table-view /)和[this](http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/3481-uitableview-tutorial-part-2 -a.html)和[this](http://www.icodeblog.com/2008/08/08/iphone-programming-tutorial-populating-uitableview-with-an-nsarray/)和[this](https: //www.google.es/search?sugexp=chrome,mod=17&sourceid=chrome&ie=UTF-8&q=uitableview+example) – sonxurxo

回答

4

我想你有一個自定義的UITableViewCell。

cellForRowAtIndexPath代表的UITableView的只需使用(設置圖像): -

yourCustomCellObject.yourImageViewINCustCell.image=[UIImage imageNamed:[(yourClassToStoreData *)[yourNSMutableArray objectAtIndex:indexPath.row] userThumb]]; 

類似地,可以以相同的方式做設置其他控制元件。

這只是你如何做的一個例子。我假設你已經將數據存儲在某些類對象上並將其添加到NSMtableArray中。

相關問題