我试图限制用户在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) 我试图在用户将页面切换到我的子片段时调用一个函数.但是,当我尝试使用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) 如何更改项目名称以下?
以下是我已经做过的一些配置,但仍显示我以前的项目名称.
<key>CFBundleDisplayName</key>
<string>ABCD</string>
<key>FacebookDisplayName</key>
<string>ABCD</string>
Run Code Online (Sandbox Code Playgroud)
编辑
Facebook设置
前三个答案可以解决我的问题。很难选择哪一个是最好的。因此,我只选择第一个回答我问题的人。对不起,业余爱好者和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) 答案:在每个视图控制器中使用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) 我试图将字典转换为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) 我正在尝试执行一个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) 是否可以将所有图像设置为相同的尺寸?我试过使用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) 我想要
视图控制器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中显示标签栏对我来说没有意义.但是,我无法想象我应该做些什么来解决这个问题.有什么建议?谢谢.
删除 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 的路径。
我有两个问题。
我想知道为什么我的集合视图无需调用即可自动加载数据imageCollectionView.reloadData()。
解决了。查看评论
为什么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) 单击单元格后,我找不到为什么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)
点击之前,
点击后,
swift ×8
ios ×4
cell ×2
segue ×2
tabbar ×2
uitableview ×2
xcode ×2
android ×1
apache ×1
back-button ×1
cocoapods ×1
composer-php ×1
cpanel ×1
dictionary ×1
facebook ×1
frameworks ×1
hide ×1
iframe ×1
image ×1
imageview ×1
javascript ×1
json ×1
mbstring ×1
overflow ×1
php ×1
podfile ×1
reloaddata ×1
size ×1
uiimageview ×1
viewdidload ×1
visibility ×1