开发者

Table View similar the Add Contact within a Modal View

开发者 https://www.devze.com 2023-02-28 04:43 出处:网络
How would I create a UITableView similar to the Add Contact or Add Event ones within a Modal View? I know how to create my Modal View and put a UITableView in it, but how would I c开发者_如何转开发re

How would I create a UITableView similar to the Add Contact or Add Event ones within a Modal View?

I know how to create my Modal View and put a UITableView in it, but how would I c开发者_如何转开发reate the grouped editable cells, the add photo button etc. within a UITableView?

I'm assuming what is in the Add Contact Modal View is indeed a UITableView, if not, how would I recreate this anyway with my custom fields for input?

Thanks.


In Add Contact there are custom cell in table view with an background image and for editable mode there are textfields. So what i am trying to say that you can create custom cells in table with textfields and buttons.


I think a table view is not the best way to go about this. Although it looks like a grouped table view, the add to contacts is highly customised.

One of the main advantages of a table view is having a dynamic size. For the contacts view it is mostly fixed.

Create a view controller and add images, text views and labels is my advice.


I finally figured out how to do this with help from saadnib. Thanks!

I created custom UITableViewCells in the same xib as the TableView and assigned them as IBOutlets in the classes @interface.

Then in tableView:cellForRowAtIndexPath: I just checked the row and returned the correct cell in the order I wanted them in since what I was trying to do just required static table cells.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return cell0;
    }
    if (indexPath.row == 1) {
        return cell1;
    }
    if (indexPath.row == 2) {
        return cell2;
    }
    return cell0;
}

I had tried to do this countless times before without it working, this was because the cells I was trying to return were null because the class didn't know where they were because they hadn't been loaded into memory from the nib file. Thus, adding this line of code in viewDidLoad: was necessary.

[[NSBundle mainBundle] loadNibNamed:@"MyNibFile" owner:self options:nil];

Everything seems to work fine now, thanks for your help.

0

精彩评论

暂无评论...
验证码 换一张
取 消