1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
//
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
//获取数据
NSString
*
str
=
[
self
.
data
objectAtIndex
:indexPath
.
row
]
;
//初始化响应链,起始为tableview开始
UIResponder
*
responder
=
[
self
.
tableview
nextResponder
]
;
//直到找到类为uiviewcontroller的类时结束循环
while
(
!
[
responder
isKindOfClass
:
[
UIViewController
class
]
]
)
{
responder
=
[
responder
nextResponder
]
;
}
//初始化second
SecondViewController
*
second
=
[
[
SecondViewController
alloc
]
initWithData
:str
]
;
//通过responder找到旗下的navigationController,初始化nav
UINavigationController
*
nav
=
(
(
UIViewController
*
)
responder
)
.
navigationController
;
//推到Second
[
nav
pushViewController
:second
animated
:YES
]
;
[
second
release
]
;
}
|
UIResponder响应链 找到需要的视图或controller
最新推荐文章于 2024-08-17 20:13:06 发布