欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

如何获取view的controller

程序员文章站 2022-03-16 14:32:56
...

[b]如何获取view的controller[/b]

//获取view的controller
- (UIViewController *)viewController {
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
//点击提交按钮
-(void)buttonPress{

ElectronFrom *electronForm=[[ElectronFrom alloc]init];
[[self viewController].navigationController pushViewController:electronForm animated:YES];
[electronForm release];

}


相关标签: view controller