小编luc*_*eer的帖子

UILongPressGestureRecognizer中断tableView滚动

我创建了一个包含UILongPressGestureRecognizer的自定义Label类,我在TableViewController中的tableview单元格中调用它.长按手势识别器工作(属性sting中的两个可点击区域),但如果滚动手势在我的CustomLabel的UILongPressGestureRecognizer区域之一开始,则包含标签的tableView不再滚动(平移).我已尝试过cancelsTouchesInView = false以下各种回复,但无济于事.任何建议将不胜感激.我花了一个星期来解决这个问题.我的代码如下.

这是CustomLabel类:

class CustomLabel: UILabel {

    let layoutManager = NSLayoutManager()
    let textContainer = NSTextContainer(size: CGSize.zero)
    var textStorage = NSTextStorage() {
        didSet {
            textStorage.addLayoutManager(layoutManager)
        }
    }

    var onCharacterTapped: ((_ label: UILabel, _ characterIndex: Int, _ state: Bool) -> Void)?

    let tapGesture = UILongPressGestureRecognizer()

    override var attributedText: NSAttributedString? {
        didSet {
            if let attributedText = attributedText {

                if attributedText.string != textStorage.string {

                textStorage = NSTextStorage(attributedString: attributedText)

                DispatchQueue.main.async {

                    let characterDelay = TimeInterval(0.01 + Float(arc4random()) /  Float(UInt32.max)) / 100 …
Run Code Online (Sandbox Code Playgroud)

uilabel ios uitapgesturerecognizer swift

5
推荐指数
1
解决办法
811
查看次数

Firebase 电子邮件验证不适用于 ActionCodeSetting

我正在尝试实现对用户电子邮件的验证(使用电子邮件模板中的默认验证 URL),以及 ActionCodeSetting URL(动态链接)以将用户带回应用程序。我对 Firebase 的 ActionCodeSetting 电子邮件验证应该如何工作感到困惑。我已阅读文档的每个可用页面,但我仍然不清楚如何正确配置“继续 URL”以不抢占和覆盖默认验证 URL。

我做了什么:

  1. 我使用自动生成的电子邮件验证链接测试了电子邮件验证。有效。
  2. 然后,我添加了一个 ActionCodeSetting URL,该 URL 使用添加到 XCode 项目的关联域中的域。这可以让用户在单击验证链接后返回到应用程序。
  3. 问题:电子邮件验证不再有效。

这是我已经实现的代码:

var actionCodeSettings = ActionCodeSettings.init()
                actionCodeSettings.handleCodeInApp = true
                let user = Auth.auth().currentUser
                let urlString = "https://blaproject.page.link/zCB4"
                actionCodeSettings.setIOSBundleID(Bundle.main.bundleIdentifier!)
                actionCodeSettings.setAndroidPackageName("com.example.android", installIfNotAvailable:true, minimumVersion:"12")

                Auth.auth().currentUser?.sendEmailVerification(with: actionCodeSettings, completion: { (error) in
                    print("verification email sent")
                    print("action code setting URL is: \(String(describing: actionCodeSettings.url))")
                })
Run Code Online (Sandbox Code Playgroud)

以下是 Firebase 控制台中电子邮件模板的默认验证 URL:

https://blaproject-ea9d6.firebaseapp.com/__/auth/action?mode= &oobCode=

这是上面代码发送的验证 URL:

https://blaproject.page.link?link=https://blaproject-ea9d6.firebaseapp.com/ /auth/action?apiKey%3DAIzaSyAi1fxd-HdkfXzYJxTpwmB3_mVCy5gvWxA%26mode%3DverifyEmail%26oobCode%3DqjvGoqc1n3ya0OIi_tWIYTpp59DYKgB6Sbj 0EymN2IkAAAFkYNutMA%26ContinueUrl%3Dhttps://blaproject .page.link/zCE4%26lang%3Den&apn=com.example.android&amv=12&ibi=blaproject.blaprojectV0-2&ifl=https://blaproject-ea9d6.firebaseapp.com/ /auth/action?apiKey%3DAIzaSyAi1fxd-HdkfXzYJxTpwmB3_mVCy5gvWxA%26mode% 3DverifyEmail%26oobCode%3DqjvGoqc1n3ya0OIi_tWIYTpp59DYKgB6Sbj0EymN2IkAAAFkYNutMA%26ContinueUrl%3Dhttps://blaproject.page.link/zCE4%26lang%3Den

所以我的问题是,为什么此 URL 不验证用户的电子邮件,然后使用继续 URL(以及关联的域)来触发应用程序打开?它仅触发应用程序打开,而不验证用户的电子邮件。

感谢您提供的任何提示来帮助我理解我不理解的内容:)

email-verification firebase ios-universal-links firebase-dynamic-links

4
推荐指数
1
解决办法
4587
查看次数

仅当尚未缓​​存时如何使用SDWebImageManager下载图像?

我需要SDWebImageManager的完成处理程序功能(以将下载或缓存的图像设置为黑白),因此我使用它而不是sd_setimage。我的问题是我不知道如何使用SDWebImageManager下载或获取图像的缓存版本。每次将tableview单元出队并重新加载时,图像都会重新下载。我尝试设置选项:SDWebImageDownloaderOptions.useNSURLCache,但无济于事。任何建议将不胜感激!这是我的代码:

SDWebImageManager.shared().imageDownloader?.downloadImage(with:URL(string: imgURL), options: SDWebImageDownloaderOptions.useNSURLCache, progress: nil, completed: { (image, error, cacheType, url) in 
   if image != nil {
      let beginImage = CIImage(image: image!)
      let blackNwhiteImg = beginImage?.applyingFilter("CIColorControls", withInputParameters: [kCIInputSaturationKey:0.0])
      let newImage = UIImage(ciImage: blackNwhiteImg!)
      cell.button.setImage(newImage, for: .normal)
   }
})
Run Code Online (Sandbox Code Playgroud)

caching ios sdwebimage swift

3
推荐指数
2
解决办法
2210
查看次数

Material UI 如何设置网格元素垂直跨3行?

这似乎是一个基本问题,但在 Material UI 的官方文档中没有如何实现这一点的示例。

我尝试过嵌套网格,但右侧的网格元素不会跨越垂直空间。我尝试过align-items =“stretch”。

下面是屏幕截图和我的代码。感谢您的任何建议!

在此输入图像描述

return (

<Container>

  <Box>
    <Typography>Test</Typography>
  </Box>

  <Grid container spacing={3} direction="row" justify="center" alignItems="stretch">
    <Grid item xs={12}>
      <Paper className={classes.paper}>xs=12</Paper>
    </Grid>

    <Grid item xs={6} spacing={3}>
      <Grid>
        <Card className={classes.root} variant="outlined">
          <CardContent>
          <Typography className={classes.title} color="textSecondary" gutterBottom>
            Customer Profile
          </Typography>
          <Typography variant="h5" component="h2">
            Sarah Doria
          </Typography>
          <Typography className={classes.pos} color="textSecondary">
            Position
          </Typography>
          <Typography variant="body2" component="p">
            Company
            <br />
            {'"a benevolent smile"'}
          </Typography>
          </CardContent>
          <CardActions>
            <Button size="small">Learn More</Button>
          </CardActions>
        </Card>
    </Grid>

    <Grid>
      <Card className={classes.root} variant="outlined">
        <CardContent>
        <Typography className={classes.title} color="textSecondary" gutterBottom>
          Preferences …
Run Code Online (Sandbox Code Playgroud)

html javascript reactjs material-ui

3
推荐指数
1
解决办法
1万
查看次数