Pass a paramether to a view transition

83 views Asked by At

I have a class managing the transiction between two views.

In the first view I have a table of chapter and in the second the text of each chapter. Now as my sqLite table is chapter(id,title,text) I'd like to pass to the second view the id of the clicked chapter in order to query the table in the second view and sort the right text of chapter.

Ther's my code:

void GoToView( UIViewController *from, UIViewController *to){   
    /*
     * Preparo l'animazione e aggiungo la subview.
     */
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:from.view cache:YES];
        [from.view addSubview:to.view];
    [UIView commitAnimations];
}

How can I pass "1" for example if I click on "Chapter One"?

1

There are 1 answers

0
EmptyStack On

I am not sure the following is what you want. But I guess this may help you.

Create a @property in you view controller to, like,

@property(nonatomic) int chapterId;

Pass the chapter number to the view controller to while you call GoToView method.

void GoToView( UIViewController *from, UIViewController *to) {   

    [to setChapterId:chapterId]; // "chapterId" is an "int" variable

    /*
     * Preparo l'animazione e aggiungo la subview.
     */

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:from.view cache:YES];
        [from.view addSubview:to.view];
    [UIView commitAnimations];
}

In you view controller to, either in loadView of viewWillAppear method whichever suites you, do the reloading of the table.

[tableView reloadData];