小编Pak*_*ung的帖子

Javascript触摸事件在Mobile Safari中无效

我试图限制用户在iframe上触摸时滚动.所以,如果他们触摸身体,他们可以滚动.

想知道为什么下面的代码在移动Chrome中运行良好,但在Mobile Safari中无效.有什么方法可以解决这个问题吗?

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 
        <style>
            .overflowHidden {
                position:relative;
                overflow-y:hidden;
            }
            .overflowAuto {
                -webkit-overflow-scrolling: touch;
                overflow: auto;
            }
        </style>
    </head>
    <body>
        <section>
            <p>hello</p><p>hello</p><p>hello</p><p>hello</p><p>hello</p><p>hello</p><p>hello</p>
            <iframe id="appSimulator" style="background: #000000;" width="189px" height="400px" frameborder="0" scrolling="no"></iframe>
            <p>hello</p><p>hello</p><p>hello</p><p>hello</p><p>hello</p><p>hello</p><p>hello</p>
        </section>
        <script type="text/javascript">
            document.body.addEventListener('touchstart', function(){
                document.body.style.overflow="auto";
                $('body').removeClass('overflowHidden');
                $('body').addClass('overflowAuto');
            }, false)
            document.body.addEventListener('touchend', function(){
                document.body.style.overflow="hidden";
                $('body').removeClass('overflowAuto');
                $('body').addClass('overflowHidden');
            }, false)
        </script>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

编辑

移动Chrome的示例 - 这就是我想要的Safari移动版

在此输入图像描述

谢谢.

编辑2

感谢muecas的帮助.

以下是Safari Mobile的当前结果

在此输入图像描述

现行守则

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width"> …
Run Code Online (Sandbox Code Playgroud)

javascript iframe overflow addeventlistener

11
推荐指数
1
解决办法
2413
查看次数

Child Fragment的setUserVisibleHint和onResume未被调用

我试图在用户将页面切换到我的子片段时调用一个函数.但是,当我尝试使用setUserVisibleHint和onResume时,两个函数都是从我的父片段调用的.

在此输入图像描述

首先,我在中设置了一个视图寻呼机 Activity

然后在A1,A3和B1中,我有setUserVisibleHint和onResume函数.

setUserVisibleHint和onResume函数

@Override
public void setUserVisibleHint(boolean visible) {
    super.setUserVisibleHint(visible);
    Log.d("A1", "setUserVisibleHint"); // A3 for Fragment A3 and B1 for Fragment B1 
    if (visible && isResumed())
        onResume();
}
@Override
public void onResume() {
    super.onResume();
    Log.d("A1", "onResume"); // A3 for Fragment A3 and B1 for Fragment B1 
    if (!getUserVisibleHint())
        return;
}
Run Code Online (Sandbox Code Playgroud)

问题:

当我从页面A单击页面B并且视图是片段B1时,我得到(这没关系)

D/A1: setUserVisibleHint
D/B1: setUserVisibleHint
D/B1: onResume
Run Code Online (Sandbox Code Playgroud)

当我从页面B单击页面A并且视图是片段A1时,我得到(这没关系)

D/B1: setUserVisibleHint
D/A1: setUserVisibleHint
D/A1: onResume
Run Code Online (Sandbox Code Playgroud)

当我从页面B单击页面A并且视图是片段A3时,我得到(问题)

D/B1: setUserVisibleHint
D/A1: setUserVisibleHint
D/A1: onResume
Run Code Online (Sandbox Code Playgroud)

我假设打印输出应该如下所示,但我不确定为什么父片段调用的函数.

D/B1: setUserVisibleHint
D/A3: setUserVisibleHint
D/A3: …
Run Code Online (Sandbox Code Playgroud)

android visibility android-fragments android-viewpager

8
推荐指数
2
解决办法
2421
查看次数

如何更改Facebook确认对话框项目名称?

如何更改项目名称以下?

在此输入图像描述

以下是我已经做过的一些配置,但仍显示我以前的项目名称.

<key>CFBundleDisplayName</key>
<string>ABCD</string>
<key>FacebookDisplayName</key>
<string>ABCD</string>
Run Code Online (Sandbox Code Playgroud)

编辑

在此输入图像描述

Facebook设置

在此输入图像描述

xcode facebook facebook-login swift

7
推荐指数
1
解决办法
366
查看次数

如果从其他视图控制器按回,则重新加载而不重新加载。迅速

前三个答案可以解决我的问题。很难选择哪一个是最好的。因此,我只选择第一个回答我问题的人。对不起,业余爱好者和iOS爱好者。谢谢您的帮助。我很感激。

在此处输入图片说明

ViewController 1具有一个表格视图。

我的问题是,仅当我从视图控制器2单击返回时,才如何重新加载表视图;如果我从视图控制器3单击返回,则不重新加载表视图。

现在,我的后退按钮代码是

@IBAction func backButtonTapped(sender: AnyObject) {
    self.dismissViewControllerAnimated(true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

在视图控制器1中。我知道将从视图控制器2或3重新加载表视图。

override func viewDidAppear(animated: Bool) {
    loadTable()
}
Run Code Online (Sandbox Code Playgroud)

我试图将loadTable()放在viewDidLoad中,并尝试在视图控制器2中为后退按钮编写以下代码。但是,它不起作用。

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewControllerWithIdentifier("UserHomePageViewController") as! UserHomePageViewController
controller.viewDidLoad()
Run Code Online (Sandbox Code Playgroud)

有什么建议我该怎么办?谢谢您的帮助。

编辑:

我认为这是一种更简单的方法,但是仍然无法如我所愿。我猜这是因为viewDidAppear是在调用reloadTableBool之前执行的。正确?有什么办法可以解决?谢谢。您的帮助将不胜感激。

class 2ViewController
@IBAction func backButtonTapped(sender: AnyObject) {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let controller = storyboard.instantiateViewControllerWithIdentifier("1ViewController") as! 1ViewController
        print("viewcontroller2 before call: \(controller.reloadTableBool)")
        controller.reloadTableBool = false
        print("viewcontroller2 after call: \(controller.reloadTableBool)")
        self.dismissViewControllerAnimated(true, completion: nil)
    }
class 1ViewController
var reloadTableBool = …
Run Code Online (Sandbox Code Playgroud)

back-button viewdidload viewdidappear ios swift

6
推荐指数
1
解决办法
8752
查看次数

按下/后退时隐藏/显示标签栏.迅速

答案:在每个视图控制器中使用self.tabBarController?.tabBar.hidden而不是hidesBottomBarWhenPushed来管理视图控制器是否应显示标签栏.

override func viewWillAppear(animated: Bool) {
    self.tabBarController?.tabBar.hidden = true/false
} 
Run Code Online (Sandbox Code Playgroud)

我想要

视图控制器1:应显示标签栏

视图控制器2:应显示标签栏

视图控制器3:不应显示标签栏.

视图控制器4:不应显示标签栏.

我写

// prepareForSegue in view controller 1, 
    let upcoming = segue.destinationViewController as! viewcontroller3
    upcoming.hidesBottomBarWhenPushed = true

// in view controller 3,
    func clickOnButton(button: UIButton) {
        self.hidesBottomBarWhenPushed = false
        self.performSegueWithIdentifier("viewController2", sender: self)
        self.hidesBottomBarWhenPushed = true
    }
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "viewController2" {
            let upcoming = segue.destinationViewController as! viewController2
            upcoming.hidesBottomBarWhenPushed = false
        }
    }
// prepareForSegue in view controller 2
    let …
Run Code Online (Sandbox Code Playgroud)

hide tabbar uiviewcontroller segue swift

6
推荐指数
4
解决办法
2万
查看次数

如何将字典转换为没有空格和新行的json字符串

我试图将字典转换为json字符串,没有空格和新行.我试图使用JSONSerialization.jsonObject,但我仍然可以看到空格和新行.有没有办法让字符串结果看起来像这样

"data": "{\"requests\":[{\"image\":{\"source\":{\"imageUri\":\"https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png\"}},\"features\":[{\"type\":\"LOGO_DETECTION\",\"maxResults\":1}]}]}"
Run Code Online (Sandbox Code Playgroud)

我的转换

var features = [[String: String]]()
for detection in detections {
    features.append(["type": imageDetection[detection]!])
}
let content = ["content": base64Image]
let request = ["image": content, "features": features] as [String : Any]
let requests = ["requests": [request]]

let jsonData = try! JSONSerialization.data(withJSONObject: requests, options: .prettyPrinted)
let decoded = try! JSONSerialization.jsonObject(with: jsonData, options: [])
print(decoded)
Run Code Online (Sandbox Code Playgroud)

结果

{
    requests =     (
                {
            features =             (
                                {
                    type = "LABEL_DETECTION";
                },
                                {
                    type = "WEB_DETECTION";
                },
                                {
                    type = "TEXT_DETECTION";
                }
            ); …
Run Code Online (Sandbox Code Playgroud)

json dictionary swift

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

Composer 安装 - 需要 ext-mbstring

我正在尝试执行一个composer install ...,但出现错误,提示requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.我正在使用 Apache (Cpanel) 和 PHP 5.6。

以下是我尝试修复错误的方法。

1: yum search mbstring

============================================= N/S matched: mbstring =============================================
ea-php54-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php55-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php56-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php70-php-mbstring.x86_64 : A module for PHP applications which need …
Run Code Online (Sandbox Code Playgroud)

php apache cpanel mbstring composer-php

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

使用cell.imageView.image的不同大小的图像.迅速

是否可以将所有图像设置为相同的尺寸?我试过使用cell.imageView?.frame.size.width = something.但是,它不起作用.有什么建议?谢谢.

在此输入图像描述

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell")
    cell.imageView!.layer.cornerRadius = 20
    cell.imageView!.clipsToBounds = true
    let imageData = try! resultsImageFileArray[indexPath.row].getData()
    let image = UIImage(data: imageData)
    cell.imageView?.image = image

    cell.textLabel?.text = self.resultsNameArray[indexPath.row]
    cell.detailTextLabel?.text = self.message3Array[indexPath.row]

    return cell
}
Run Code Online (Sandbox Code Playgroud)

size cell uitableview imageview swift

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

如何在按下时隐藏标签栏并在返回时显示标签栏

我想要

视图控制器1:显示标签栏

视图控制器2:显示标签栏

视图控制器3:未显示标签栏.

我写

// prepareForSegue in view controller 1, 
let upcoming = segue.destinationViewController as! viewcontroller3
upcoming.hidesBottomBarWhenPushed = true

// prepareForSegue in view controller 3,
let upcoming = segue.destinationViewController as! viewcontroller2
self.hidesBottomBarWhenPushed = true
Run Code Online (Sandbox Code Playgroud)

当我从视图控制器1查看控制器3时,未显示标签栏.然后,我从视图控制器3查看控制器2,显示标签栏.但是当我在视图控制器2中轻击时,在视图控制器3 self.hidesBottomBarWhenPushed = true显示标签栏对我来说没有意义.但是,我无法想象我应该做些什么来解决这个问题.有什么建议?谢谢.

在此输入图像描述

tabbar uiviewcontroller ios segue swift

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

Xcode 删除 pod 文件后如何删除框架

删除 pod 文件后,出现错误

ld: framework not found Alamofire
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

想知道在哪里可以删除框架?尝试去目标,然后去链接框架和库。我看不到 Alamofire 框架存在。另外,在框架搜索路径中,我也看不到 Alamofire 的路径。

xcode frameworks ios cocoapods podfile

2
推荐指数
1
解决办法
1316
查看次数

uicollectionview-数据自动加载而无需调用reloaddata

我有两个问题。

  1. 我想知道为什么我的集合视图无需调用即可自动加载数据imageCollectionView.reloadData()

    解决了。查看评论

  2. 为什么func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize不叫?我没有看到print("collectionViewLayout called")我正在尝试修改单元格的大小,因此单元格的高度等于集合视图的高度

    解决了。查看评论

这是代码

class ProductInternalDetailVC: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {

    var selectedProduct: Product?
    @IBOutlet weak var imageCollectionView: UICollectionView!

    override func viewDidLoad() {
        super.viewDidLoad()
        imageCollectionView.delegate = self
        imageCollectionView.dataSource = self
    }

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 2
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath as …
Run Code Online (Sandbox Code Playgroud)

reloaddata ios uicollectionview uicollectionviewcell swift

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

cell.imageView!.frame size change.迅速

单击单元格后,我找不到为什么cell.imageView会发生变化的原因.似乎只有宽度变化.在我的代码中,图像框架应该是第二张图片中的iPhone.

imageView是Swift内置的,而不是tableviewcell的自定义名称.

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
    if tableView == resultsTable {
        let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MarketCell")
        var supplyDetail = String()

        var frame = cell.imageView!.frame
        let imageSize = 50 as CGFloat
        frame.size.height = imageSize
        frame.size.width  = imageSize
        cell.imageView!.frame = frame
        cell.imageView!.layer.cornerRadius = imageSize / 2.0
        cell.imageView!.clipsToBounds = true

        cell.imageView?.image = UIImage(named: "Profile Picture")
        ...getDataInBackgroundWithBlock...
            cell.imageView?.image = UIImage(data: data!)!
        return cell

    } 
}
Run Code Online (Sandbox Code Playgroud)

点击之前,

在此输入图像描述

点击后,

在此输入图像描述

image cell uitableview uiimageview swift

0
推荐指数
1
解决办法
5750
查看次数