将参数传递给视图转换
我有一个类管理两个视图之间的转换。
在第一个视图中,我有一个章节表,在第二个视图中,我有每章的文本。 现在,由于我的 sqLite 表是 Chapter(id,title,text),我想将单击的章节的 id 传递给第二个视图,以便查询第二个视图中的表并对章节的正确文本进行排序。
这是我的代码:
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];
}
例如,如果我单击“第一章”,如何传递“1”?
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"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定以下内容是您想要的。但我想这可能对你有帮助。
在视图控制器
to
中创建一个@property
,例如,在调用
GoToView< 时将章节编号传递给视图控制器
to
/代码> 方法。在您的视图控制器
to
中,无论是在viewWillAppear
方法的loadView
中还是在适合您的方法中,重新加载表格。I am not sure the following is what you want. But I guess this may help you.
Create a
@property
in you view controllerto
, like,Pass the chapter number to the view controller
to
while you callGoToView
method.In you view controller
to
, either inloadView
ofviewWillAppear
method whichever suites you, do the reloading of the table.