1.背景:因为程序要用到Notification,传值给一个按钮事件。按钮事件的传入参数是(id)sender,因此要通过转换sender来获得notification的传入值。
2.代码:
-(void)onCustomLeftButtonClick:(id)sender {
if ([sender isKindOfClass:[NSNotification class]]) {
NSString *showType = [sender object];
if ([@"show_left" isEqualToString:showType]) {
_slider_btn_flag = 101;
return;
}else if ([@"show_center" isEqualToString:showType]){
_slider_btn_flag = 100;
return;
}
}
。。。。。
本文介绍了一种在iOS开发中使用Notification传递值给特定按钮点击事件的方法。通过判断sender类型为NSNotification并获取其object属性,可以实现根据不同Notification传入的showType值设置不同的_slider_btn_flag标志。
1903

被折叠的 条评论
为什么被折叠?



