基本靜態TableView的實作方法
1. 根據上一篇將MyTableViewController.m中以下所標記的程式碼,全部移除或Mark起來
/*
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
//return 0;
return [myData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = (NSString *)[myData objectAtIndex:indexPath.row];
return cell;
}
*/
2.
將Storyboard下的TableView設成Static Cell
3. 增加圖片檔到Project上,讓Table上可以出現圖案。
4. 設定Storyboard中的TableViewCell,根據紅框的部分設定就會有圖上的效果,其它項目也可自行設定。
5. 基本設定完成,Run一下來看結果
TableViewCell的構造







沒有留言:
張貼留言