uiview类里面进行触发按钮事件来让viewcontroller进行跳转的方法
来源:互联网 发布:淘宝魅族mx5屏幕总成 编辑:程序博客网 时间:2024/05/29 08:26
1:
代理,block 都可
说实话代理不熟,一般自己定义一个UIView 中含有button ,并且button的 是push事件我都用block,回调到调用该view的ViewContronller中用
[self.navigationController pushViewController:secondVC animated:YES] 实现push事件。
或者还可以这样
假定你的项目中有文件 UIViewContronller1(继承UIViewContronller), UIViewContronller2(继承于UIViewContronller),UIViewWithButon(继承于UIView)
UIViewWithButon中有一button
在UIViewContronller1中调用UIViewWithButon
目的是:点UIViewWithButon上的Button就会从UIViewContronller1 push到 UIViewContronller2
实现是:
在UIViewWithButon.h文件 @property (nonatomic,strong) UIViewController *owner;
在UIViewWithButon.m文件中button 的方法中 [self.owner.navigationController pushViewController:[UIViewContronller2 new] animated:YES];
在UIViewContronller1,.m中调用UIViewWithButon
UIViewWithButon *buttonView = [[UIViewWithButon alloc]initwith...];
buttonView.owner = self;
2:
用代理 首先在view 中 声明协议
.h文件
@protocol AccountBindingDelegate <NSObject>
- (void)jumpWebVC:(UIButton*)sender;
@end
@interface CustomRegisterView : UIView
@property (nonatomic, weak) id<AccountBindingDelegate> delegate;
@end
.m文件
[agreementBtn addTarget:self action:@selector(agreementBtnClick:) forControlEvents:UIControlEventTouchUpInside];//button的点击方法
- (void)agreementBtnClick:(UIButton*)sender
{
if (self.delegate && [self.delegate respondsToSelector:@selector(jumpWebVC:)]) {
[self.delegate jumpWebVC:sender];
}
}
在controller中
@interface uiviewContrller ()<AccountBindingDelegate> //遵守协议
@end
- (void)viewDidLoad {
_registerView.delegate = self;//设置代理
}
//实现方法
- (void)jumpWebVC:(UIButton*)sender
{
PSMFWebVC *webVC = [PSMFWebVC new];
UIBarButtonItem *backItem = [UIBarButtonItem new];
backItem.title = @"返回";
self.navigationItem.backBarButtonItem = backItem;
[self.navigationController pushViewController:webVC animated:YES];
}
- uiview类里面进行触发按钮事件来让viewcontroller进行跳转的方法
- javaweb当中通过点击一个按钮来触发事件进行制定页面的跳转操作
- NavigationController 进行指定ViewController之间的跳转
- NGUI另一种按钮事件触发的方法
- jquery validation 在触发按钮单击事件进行表单校验和验证通过后发起ajax请求的解决方案
- 关于多个ViewController之间进行数据传递的方法
- 单击按钮进行页面跳转
- ViewController页面跳转的方法
- js在insertRow里面触发事件的方法
- js监听Enter事件的触发进行查找
- 如何实现点击UITableViewCell中的控件,能调用到所在的ViewController对象进行页面跳转
- jQuery实现长按按钮触发事件的方法
- jQuery实现长按按钮触发事件的方法
- 代码触发两个按钮相同的点击事件方法
- C#触发按钮的事件
- unity3d点击按钮进行场景跳转的代码
- 让android的webview中的按钮,触发事件,也能像原生按钮一样使用
- gridview里面点击某一数据进行跳转
- java基础—— Collections.sort的两种用法
- java 时间类型(date)与时间字符串(string)转换
- spring pom文件报错:提示no declaration can be found for element 'dubbo:service'.
- gcc升级
- [C#] 使用WebSocket进行通讯
- uiview类里面进行触发按钮事件来让viewcontroller进行跳转的方法
- 从留言板开始做网站(八)——客户端的数据验证(JS验证方法)
- android存储目录
- 通过命令行来查看mysql数据库中的表
- LeetCode 28. Implement strStr()
- Scala版SparkStreaming读写kafka,low level api模板代码存档
- 瑞萨单片机学习
- 安装hadoop1.2.1集群环境
- CocoaPods详解之----进阶篇