objective-c – addTarget:action:forControlEvents – TableV
发布时间:2020-12-16 09:34:28 所属栏目:百科 来源:网络整理
导读:使用此论坛中的精彩帖子,我在tableView中创建了一个switchView作为accessoryView.当触摸开关时,我的动作(switchChanged)被调用.只有发送方具有有效值,事件为0x0. 将目标添加到switchView: [switchView addTarget:self action:@selector(switchChanged:forEv
使用此论坛中的精彩帖子,我在tableView中创建了一个switchView作为accessoryView.当触摸开关时,我的动作(switchChanged)被调用.只有发送方具有有效值,事件为0x0.
将目标添加到switchView: [switchView addTarget:self action:@selector(switchChanged:forEvent:) forControlEvents:(UIControlEventValueChanged | UIControlEventTouchDragInside)]; 那个行动: - (void) switchChanged:(id)sender forEvent:(UIEvent *)event { if(event) { NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:[[[event touchesForView:sender] anyObject] locationInView:self.tableView]]; IFDFlightlogFormQuestions *question = [self.resultsController objectAtIndexPath:indexPath]; NSLog(@"IFDNewFlightlogViewController_Pad:switchChanged Switch is %@ xmlAttrib %@",[sender isOn],question.XmlAttrib); [self.xmlResults setValue:([sender isOn])?@"true":@"false" forKey:question.XmlAttrib]; } } 使用动作:@selector(switchChanged:forEvent (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |