我已经能够与Whatsapp分享照片,但我这样做的方法是在a中提供Whatsapp选项UIActivityViewController,然后显示一个UIDocumentInteractionController.
从这里UIDocumentInteractionController,我选择Whatsapp选项,将用户重定向到Whatsapp并让他分享照片.
到目前为止我的代码是这样的:
if ([activityType isEqualToString:@"whatsappSharing"]) {
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]) {
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];
[UIImageJPEGRepresentation(finalImage, 1.0) writeToFile:savePath atomically:YES];
weakDocumentInteraction = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
weakDocumentInteraction.UTI = @"net.whatsapp.image";
weakDocumentInteraction.delegate = weakSelf;
[weakDocumentInteraction presentOpenInMenuFromRect:CGRectZero inView:weakSelf.view animated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
我希望能够从a中选择UIActivityViewController并直接显示Whatsapp.
有没有办法跳过第二部分呈现UIDocumentInteractionController并以编程方式选择Whatsapp应用程序选项?
目前,用户必须选择两次Whatsapp选项才能共享图像.
PS:我正在使用,UIActivityViewController因为我也在使用其他活动.
objective-c ios uidocumentinteraction whatsapp uiactivityviewcontroller
我有一个UITableView与包含UILabel的单元格.UILabel有一个自定义的UIEdgeInset.我将UILabel子类化并设置UIEdgeInsets如下:
override func drawText(in rect: CGRect) {
super.drawText(in: UIEdgeInsetsInsetRect(rect, insets))
}
override var intrinsicContentSize: CGSize {
var contentSize = super.intrinsicContentSize
contentSize.width += leftInset + rightInset
contentSize.height += topInset + bottomInset
return contentSize
}
Run Code Online (Sandbox Code Playgroud)
但是当我在UILabel中有更多行时,标签有时会被截断.我已经将行高配置为UITableViewAutomaticDimension并设置了estimatedRowHeight.约束也很好.问题似乎是我正在设置UIEdgeInsets,因为如果我不自定义它可以正常工作.
可能我应该告诉单元格在设置insets后更新约束,但到目前为止我无法做到这一点.
故事板中添加的约束.Bottom,Top,Leading并且Trailing都与上海华盈(UITableViewCell中).所有常量都设置为0.
在cellForRowAtIndexPath代码中如下:
let cell = tableView.dequeueReusableCell(withIdentifier: "AnswersCell", for: indexPath) as! AnswerCell
cell.answerLabel.text = alternatives[indexPath.row]
return cell
Run Code Online (Sandbox Code Playgroud)