我正在使用a进行幻灯片菜单,菜单上UITableView有2个选项,我想在底部放置一个按钮,如下图所示:

我试着这样做添加一个tableFooterView.
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 500, 320, 70)];
footerView.backgroundColor = [UIColor blackColor];
self.tableView.tableFooterView = footerView;
Run Code Online (Sandbox Code Playgroud)
但是,视图出现在第二个单元格之后,但我希望它位于底部.
感谢帮助.
我正在使用一个故事板应用simples一个有一个视图UITableView与UITableViewCell那些导航到另一个UIView.
所以必须编写代码来填充表视图上的单元格.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"SampleCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
NSLog(@"cai no init da cell");
}
GPItem *item = [self.items objectAtIndex:indexPath.row];
cell.textLabel.text = @"Post";
cell.detailTextLabel.text = item.imageURL;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
我意识到代码if (cell == nil) { ...永远不会执行所以我真的需要这样做才能使用Storyboard中的单元格吗?
谢谢.
是否有一种模式或最佳选择来改进此方法并减少重复的ifs?
我已经使用Adapter模式将接口转换为另一个接口.
public string GetInvoice(int id)
{
// Search in Mongodb and get the object
var invoice = MongoRepository.Get<IInvoiceEntity>(x => x.Invoice.Id == id)
.First();
if (invoice == null)
{
// Search in SQL
invoice = EFRepository.Get<IInvoiceEntity>(x => x.Invoice.Id == id)
.First();
}
if (invoice == null)
{
// This invoice is an old system item
var oldInvoice = WCFClient.InvoiceService.Get(id);
var adapter = new OldInvoiceAdapter(oldInvoice);
invoice = adapter.AdaptEntity();
}
return invoce.ToJson();
}
Run Code Online (Sandbox Code Playgroud)
谢谢!