Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案
http://qmuiteam.com/ios
Other
7.05k stars 1.37k forks source link

集成QMUI后,调起CNContactViewController进行联系人编辑,点击右上方“完成”按钮后,didCompleteWithContact回调不执行 #1369

Closed yyks999 closed 1 year ago

yyks999 commented 2 years ago

Bug 表现 集成QMUI后,调起CNContactViewController进行联系人编辑,点击右上方“完成”按钮后,didCompleteWithContact回调不执行

截图 Xnip2022-01-21_17-43-14 Xnip2022-01-21_17-34-45 Xnip2022-01-21_17-34-55

如何重现

  1. 使用CNContactViewController进入联系人信息编辑页面
  2. 点击右上角“完成”按钮
  3. 无法回调didCompleteWithContact方法,XCode报错

其他信息

使用QMUIDemo复现,复现代码: QMUIDemo_iOS4.4.2-master.zip

xixisplit commented 2 years ago

`- (instancetype)initWithCoder:(NSCoder *)coder{ return [self init]; }

yyks999 commented 2 years ago

暂时注释掉了UITextInputTraits+QMUI.m中的这段代码,注释后回调正常执行

OverrideImplementation([inputClasses class], @selector(initWithCoder:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) {
       return ^UIView<UITextInputTraits> *(UIView<UITextInputTraits> *selfObject, NSCoder *firstArgv) {

            // call super
            UIView<UITextInputTraits> * (*originSelectorIMP)(id, SEL, NSCoder *);
            originSelectorIMP = (UIView<UITextInputTraits> * (*)(id, SEL, NSCoder *))originalIMPProvider();
            UIView<UITextInputTraits> * result = originSelectorIMP(selfObject, originCMD, firstArgv);
            result.qti_didInitialize = YES;
            return result;
         };
});
MoLice commented 1 year ago

没遇到你说的问题。

image
kuangzihan commented 10 months ago

没有遇到你说的问题。 图像

CNMutableContact *newContact = [[CNMutableContact alloc] init];
newContact.givenName = @"张三";

// 创建一个可变数组来存储号码
NSMutableArray *phoneNumbers = [NSMutableArray array];

// 创建第一个号码
CNPhoneNumber *phoneNumber1 = [[CNPhoneNumber alloc] initWithStringValue:@"1234567890"];
CNLabeledValue *phoneNumberValue1 = [CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMain value:phoneNumber1];
[phoneNumbers addObject:phoneNumberValue1];

// 创建第二个号码
CNPhoneNumber *phoneNumber2 = [[CNPhoneNumber alloc] initWithStringValue:@"9876543210"];
CNLabeledValue *phoneNumberValue2 = [CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMobile value:phoneNumber2];
[phoneNumbers addObject:phoneNumberValue2];

// 创建第三个号码
CNPhoneNumber *phoneNumber3 = [[CNPhoneNumber alloc] initWithStringValue:@"5555555555"];
CNLabeledValue *phoneNumberValue3 = [CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberHomeFax value:phoneNumber3];
[phoneNumbers addObject:phoneNumberValue3];

newContact.phoneNumbers = phoneNumbers;

CNContactViewController *vc = [CNContactViewController viewControllerForNewContact:newContact];

vc.allowsEditing = YES;
vc.allowsActions = YES;
vc.delegate = self;
vc.displayedPropertyKeys = @[CNContactGivenNameKey,
                             CNContactPhoneNumbersKey,
                             CNContactOrganizationNameKey,
                             CNContactDepartmentNameKey,
                             CNContactJobTitleKey,
                             CNContactNoteKey,
                             CNContactPostalAddressesKey,
                             CNContactInstantMessageAddressesKey
];
self.contactVC = vc;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
vc.navigationItem.leftBarButtonItems = @[[[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:self action:@selector(dismissContactsViewController)]];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:nav animated:YES completion:nil];

添加多个号码就会出现,只添加一个不会。 不单单是号码,像一些社交信息也一样,加一个没事,多个就不行了。这是个bug,希望能解决掉。