开发者

How do I implement a login screen that uses TableView for an iphone application

I want to use a TableView fo开发者_StackOverflow社区r representing a Username/Password textfields dialog in a nice and grouped view. I figured the best case is to use the TableView and two cells for this.

I kind of got lost in the implementation... Is there any built in cells for this that I am missing?


What you probably want to do is make a custom UITableViewCell subclass with properties for the textfield(s) you need. Create the nib file for your new cell type, lay it out as desired. Set the "file's owner" class to your UITableViewController class, and create a connection from an outlet (say, "newCell") in the "file's owner" to your custom cell.

Then when you need to create a cell (inside tableView: cellForRowAtIndexPath:), you can load it from the nib:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  // Reuse or create cell
  MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
    // load from nib, reference into self.newCell
    [[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil];
    cell = self.newCell;
    self.newCell = nil;    // don't need to hang on to the memory
  }
  return cell;
}


Check out three20, it might have exactly what you are looking for.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜