mik*_*kez 3 iphone objective-c ios
我试图像我这样覆盖我的cellForRowAtIndexPath方法中的方法
cell.customSwitch {
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
[super touchesEnded:touches withEvent:event];
NSLog(@"customSwitch touchesended");
}
};
Run Code Online (Sandbox Code Playgroud)
但这不起作用(我通常是一个Java人:P).任何帮助将非常感激!
Objective-C和Java之间有很多相似之处,但那不是它们之一.;-)
如果要使用自定义-touchesEnded:withEvent:方法创建单元格,则需要单独声明和定义该类.就像是:
@interface MyCell : UITableViewCell
{
//...
}
@end
@implementation MyCell
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
[super touchesEnded:touches withEvent:event];
NSLog(@"customSwitch touchesended");
}
@end
Run Code Online (Sandbox Code Playgroud)
完成后,您可以使用MyCell -cellForRowAtIndexPath:.
| 归档时间: |
|
| 查看次数: |
2239 次 |
| 最近记录: |