【问题标题】:ipad pop over with text field to enteripad 弹出文本框以输入
【发布时间】:2013-03-03 20:44:01
【问题描述】:

我为 ipad 设计了一个弹出窗口(tableview 样式)。现在就像在 asp.net 中一样,我希望最后有一个选项,这样如果用户单击它,他就可以在其中输入值。可以吗?如果可以怎么办?我玩过 tableviewcellstyles 并得到了一个文本框,但适用于所有选项。如果有人做过,你能给我一些想法吗?谢谢。

编辑:我应该提到我正在使用 Monodevelop 开发这个应用程序。

【问题讨论】:

    标签: ios ipad styles uitextfield popover


    【解决方案1】:

    一种方法,假设您使用 Storyboard 创建视图和设置属性:

    在您的 UITableView 对象属性中,将“content”属性设置为“Dynamic Prototypes”。

    然后从情节提要编辑器的 UI 对象列表中向您的表格添加一个额外的表格视图单元格(就像添加另一个标签或按钮或其他任何内容一样)。

    现在您的表格视图中应该有两个 TableViewCell 对象。如果没有,请添加另一个。

    为两个表格视图单元格对象赋予不同的标识符(即,将每个属性“标识符”设置为不同的字符串)。

    设置第一个单元格以显示您的正常内容。

    设置第二个单元格以显示您独特的“最后一行”布局。

    在您的代码中,在 cellForRowAtIndexPath 中,为大多数行返回“主”单元格,但为最后一行返回备用单元格:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // rows are 0-indexed
        if (indexPath.row == myDataSource.count) {
    
            NSString *CellIdentifier = @"AlternateCell";
    
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    
            // populate contents...
        }
        else {
    
            NSString *CellIdentifier = @"NormalRow";
    
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    
            // populate contents...
        }
    }
    

    为此,您必须告诉 TableView 比您的实际数据多一行:

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return myDataSource.count +1;
    }
    

    【讨论】:

    • 谢谢。我应该提到我正在使用 Monodevelop 作为 IDE。你以前用过它吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-28
    • 2011-07-10
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多