2016-01-21 48 views
0

我想將tableview放入tableview單元格中。我喜歡它給出的格式化外觀。我希望能夠放入幾個字段,例如姓名,電子郵件等。我錯過了什麼可以完成這項工作?目前我無法將「ProfileCell」設置爲tableview類。TableViewCell中的TableView

在配置文件電池我加我的.h文件中:

@interface ProfileCell : UITableViewCell <UITableViewDataSource,UITableViewDelegate> 

,在我的.m文件我加了一些實現代碼如下基本方法:

#import "ProfileCell.h" 

@implementation ProfileCell 

- (void)awakeFromNib { 
    // Initialization code 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated { 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    // Number of rows is the number of time zones in the region for the specified section. 
    return 1; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSLog(@"Doing this"); 
    static NSString *MyIdentifier = @"MyReuseIdentifier"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 
    return cell; 
} 
@end 

enter image description here

編輯:

我哈哈已經分隔爲cellview實現代碼如下代碼到它自己的文件和鏈接的tableview這一類,但它不看火:

@interface ProfileBasicDetails : UITableView <UITableViewDataSource,UITableViewDelegate> 

每評論下面

這是我的頁面應該看起來像說完了。這是因爲用戶可以輸入他們的細節,同時看起來不錯和格式化,但沒有貧民窟的樣子。

enter image description here

+3

文檔中有一個隱藏的警告:*您不應該在UIS​​crollView對象中嵌入UIWebView或UITableView對象。如果這樣做,可能會導致意外的行爲,因爲兩個對象的觸摸事件可能會混淆並被錯誤地處理。*作爲UIScrollView的子視圖,這適用於此:不要這樣做。它有效或不可能:這是意想不到的行爲。 https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/#//apple_ref/doc/uid/TP40006950-CH3-DontLinkElementID_5 – vikingosegundo

+0

謝謝。你知道,即使它被鎖定,它是否仍然重要?我不打算滾動那個,只是讓它格式化輸入的項目,就像你在其他應用程序中看到的一樣。 – LeviXC

+1

您需要訪問源代碼才能回答此問題。我沒有那個。 – vikingosegundo

回答

0

我假設你已經嵌入的UITableView進入細胞?

您應該將桌面視圖連接到單元中的插座。然後在你的awakeFromNib方法的tableview中設置委託。

*由於vikingosegundo在評論中提到,這可能是一個非常脆弱的方法。

+1

文檔中有一個隱藏的警告:你不應該在UIS​​crollView對象中嵌入UIWebView或UITableView對象。如果這樣做,可能會導致意外的行爲,因爲兩個對象的觸摸事件可能混淆並被錯誤地處理。作爲表視圖子類UIScrollView,這適用於此:不要這樣做。它有效或不可能:這是意想不到的行爲。 https://developer.apple。com/library/ios/documentation/UIKit/Reference/UIWebView_Class /#// apple_ref/doc/uid/TP40006950-CH3-DontLinkElementID_5 – vikingosegundo

+0

同意,需要注意一些問題。禁用該視圖上的滾動,可能也會禁用用戶交互。 (嵌入式tableview上的tap不會傳遞給父級tableview等) 如果你決定這樣做,這是如何做到的。 – skwashua

+0

你只會假設它會起作用,你沒有任何保證它不會在任何時候中斷。 – vikingosegundo

相關問題