开发者

How To Load TableView Into 2nd UIView?

开发者 https://www.devze.com 2023-02-25 00:04 出处:网络
I have a tableview1 that has an add button in navbar.When you press the add button, a new uiview animates in.Currently the new view is blank.

I have a tableview1 that has an add button in navbar. When you press the add button, a new uiview animates in. Currently the new view is blank.

I want to have a table view with sub-table in this new view. It will animate out when the done button is pressed.

My question is, where do I put the code for this 2nd view table and sub table, do I make a new class or keep it with the original class?

Think of what I'm trying to do like adding favorites. I have a favorites list with an add button, I want to click the add button and bring up a table which may have a sub-table from which I can select a cell and it will dismiss this t开发者_C百科able and add the cell to the initial favorites table.


You will generally have a new class for each type of view controller in use in your app. Once you have your view controllers defined, you typically display them either by pushing onto a navigation controller or by presenting modally.

Example in FavoritesViewController.m when the add button action is invoked:

- (IBAction)addMoreFavorites
{
    AddFavoritesViewController *addFavesVC = [[[FavoritesViewController alloc] init] autorelease];

    // if using a navigation controller
    [self.navigationController pushViewController:addFavesVC];

    // if presenting modally
    [self presentModalViewController:addFavesVC];
}

To dismiss addFavesVC when done you either use [self.navigationController popViewControllerAnimated:YES] or [self dismissModalViewController]

There are many ways to implement adding new favorites to your data model and updating the UI in one or more view controller.

0

精彩评论

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