我正在尝试将 NSIndexpath 作为参数添加到方法中
[self action:@selector(showDetailedImage)];
是否可以向此方法添加额外的参数(NSIndexPath
)?
我正在尝试将 NSIndexpath 作为参数添加到方法中
[self action:@selector(showDetailedImage)];
是否可以向此方法添加额外的参数(NSIndexPath
)?
不,你不能传递参数,你只能证明这个选择器会接受那么多的参数。
如果您需要这样做,您可以创建一个属性并从方法访问它showDetailedImage
。
但是,您可以使用此选择器:
[self performSelector:@selector(showDetailedImageIndex:) withObject:objectOfNSIndex];
-(void)wrapperMethodOforiginalSelectorMethod;
对您的now-selector-method 说一个包装器(另一种方法) ,-(void)originalSelectorMethod:(id)argument;
并将包装器作为您的新选择器,它会进一步用您的参数调用您的 originalSelectorMethod。
您必须添加额外的参数
ShowDetailedImage:(NSIndexPath *)indexPath
可以调用 [self action:@selector(showDetailedImage:)];