B类继承自A类,A类要扫描二维码,B类要上传图片,同时要调用imagePickerController这个方法。
在A类里:
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
//扫描二维码也需要打开相机
}
在B类里:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if ([self.class isSubclassOfClass:[A class]]) {
//打开相册上传图片
} else {
//扫描二维码也需要打开相机 执行父类原来的方法
[super imagePickerController:picker didFinishPickingMediaWithInfo:info];
}
}
时间: 2024-12-06 00:59:43