Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Xcode:UIWebView用于刷新网站缩放时未居中的动画_Ios_Xcode_Animation_Uiwebview_Pull To Refresh - Fatal编程技术网

Ios Xcode:UIWebView用于刷新网站缩放时未居中的动画

Ios Xcode:UIWebView用于刷新网站缩放时未居中的动画,ios,xcode,animation,uiwebview,pull-to-refresh,Ios,Xcode,Animation,Uiwebview,Pull To Refresh,我用Xcode和Swift创建了一个iOS应用程序。我使用以下代码进行拉取刷新: func pullToRefresh() { self.homewebview.reload() } func addRefreshControl() { refreshControl = UIRefreshControl() refreshControl.attributedTitle = NSAttributedString(string: "Please wait a mome

我用Xcode和Swift创建了一个iOS应用程序。我使用以下代码进行拉取刷新:

func pullToRefresh() {
        self.homewebview.reload()
}
func addRefreshControl() {
    refreshControl = UIRefreshControl()
    refreshControl.attributedTitle = NSAttributedString(string: "Please wait a moment…")
    refreshControl.addTarget(self, action: #selector(FirstViewController.pullToRefresh), forControlEvents:.ValueChanged)
    self.homewebview.scrollView.addSubview(refreshControl)
}
它工作得很好,动画也显示出来了。但是,当用户放大(放大或缩小)网站并拖动以刷新动画(旋转滚轮,“请稍等…”文本)时,根据放大网站的实际显示面,文本不会居中(水平)显示

有人知道怎么解决吗

  • 检查是否正在使用
    contentInsets
    ,如果是,则将布局约束/布局定位设置为
    refreshControl.superView
    ,并设置偏移量

  • 同时设置
    tableView.refreshControl=refreshControl
    ,而不是将其作为子视图添加


  • 例如,如果您有左右插入
    leftrightsinset=CGFloat(value)

    然后,您可以使用以下代码段来集中刷新控件:

    refreshControl.bounds = CGRect(x: leftRightInset,
                                   y: refreshControl.bounds.origin.y,
                                   width: refreshControl.bounds.width,
                                   height: refreshControl.bounds.height)