[英]iOS Storyboard - creating customized UITableViewCell
我正在嘗試通過Storyboard為我的iPhone App創建一個自定義UITableViewCell(注意:這是iOS 7)。
每個單元都有點復雜,由帶有幾個標簽的UIView組成。 換句話說,我想通過自定義單元格本身的內容視圖來設置原型單元格。
這是我嘗試的步驟:
如下:
-(int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UIView *view = (UIView *)[cell viewWithTag:1];
NSLog(@"%@",view); //this just prints "(null)" a bunch of times
return cell;
}
這是我的GUI元素的層次結構。
這是我已將UIView的標簽設置為1的演示。
這是UITableView:
它多次打印(null)
。 正確的方法是什么? 我沒有成功找到通過情節UITableViewCells
構建的復雜自定義UITableViewCells
任何教程。
我認為您需要將UITableViewCell
拖放到UITableView
而不是UIView
。
這是屏幕截圖:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.