小编Gre*_*reg的帖子

在底部的UITableView中添加一个页脚

我正在使用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)

但是,视图出现在第二个单元格之后,但我希望它位于底部.

感谢帮助.

objective-c uitableview ios

6
推荐指数
2
解决办法
6789
查看次数

在Storyboard中使用UITableViewCell时使用alloc和init

我正在使用一个故事板应用simples一个有一个视图UITableViewUITableViewCell那些导航到另一个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中的单元格吗?

谢谢.

objective-c storyboard uitableview ios

2
推荐指数
1
解决办法
3881
查看次数

控制方法返回的最佳模式

是否有一种模式或最佳选择来改进此方法并减少重复的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)

谢谢!

.net c# design-patterns

1
推荐指数
1
解决办法
74
查看次数

标签 统计

ios ×2

objective-c ×2

uitableview ×2

.net ×1

c# ×1

design-patterns ×1

storyboard ×1