开发者

UITableViewController cell fadeout

I'm creating a UINavigationController based app. And in the first view i have a UITableViewController.

I want to have the same behaviour that the Contacts App have. 1) User select contact 2) System show contact details 3) User selects que back button 4) System returns to the tableview, and fadeout the cell

I can only do thi开发者_开发知识库s if i create a UIViewController, and a xib with a UITableView. And then add the following code:

- (void)viewDidAppear:(BOOL)animated{
    if ([self.mytableView indexPathForSelectedRow] != nil){
        [self.mytableView deselectRowAtIndexPath:[self.mytableView indexPathForSelectedRow] animated:YES];
    }
}

I really don't want to have a xib only for this. So is it possible to do it in with a UITableViewController?


Yes. A UITableViewController is a subclass of UIViewController so you can overide the viewDidAppear:animated method however you wish.

If you want to create the UITableViewControl programmatically (i.e. without loading it from a nib), you'll have to manually configure the UITableView. See the following in the UITableViewController class reference:

  • If a nib file is specified via the initWithNibName:bundle: method (which is declared by the superclass UIViewController), UITableViewController loads the table view archived in the nib file. Otherwise, it creates an unconfigured UITableView object with the correct dimensions and autoresize mask. You can access this view through the tableView property.
  • If a nib file containing the table view is loaded, the data source and delegate become those objects defined in the nib file (if any). If no nib file is specified or if the nib file defines no data source or delegate, UITableViewController sets the data source and the delegate of the table view to self.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜