我正在尝试"resizeLayer"通过对UIView selectedShape进行子分层来将其添加到UIView中selectedShape
let sublayer = CALayer()
sublayer.bounds = selectedShape.bounds //even when inserted this line, sublayer still doesn't show up
sublayer.frame = selectedShape.frame
sublayer.contents = UIImage(named: "resizeLayer")
selectedShape?.layer.addSublayer(sublayer)
Run Code Online (Sandbox Code Playgroud)
但是当我运行代码时,我根本看不到该层
我什至尝试"resizeLayer"通过UIView来查看图像"selectedShape"
let resizeFrame = UIImageView(image: UIImage(named: "resizeLayer"))
resizeFrame.frame = selectedShape.frame
resizeFrame.contentMode = UIViewContentMode.ScaleAspectFill
selectedShape.addSubview(resizeFrame)
Run Code Online (Sandbox Code Playgroud)
但是,仍然"resizeLayer"没有出现!
仅当我"resizeLayer"在整体视图中添加时,它才会显示:
let resizeFrame = UIImageView(image: UIImage(named: "resizeLayer"))
resizeFrame.frame = selectedShape.frame
resizeFrame.contentMode = UIViewContentMode.ScaleAspectFill
selectedShape.addSubview(resizeFrame)
self.view.insertSubview(resizeFrame, aboveSubview: selectedShape) //add this line
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
如果相关,这就是我所做的 selectedShape
selectedShape = UIView(frame: …Run Code Online (Sandbox Code Playgroud) 我有一个UIBarButton saveBarButton屏幕图像保存到相机胶卷。当用户按下saveBarButton图像被保存并且UIBarButton saveBarButton改变UIImage doneIcon为 1.2 秒时,向用户表明图像已被保存。当saveBarButton显示doneIconI disable 时saveBarButton。但是,当我这样做时,它saveBarButton会变灰。
我的问题是:如何阻止UIBarButton禁用时变灰?
我的代码:
//create UIBarButton saveBarButton
override func viewDidLoad() {
let saveBarButton = UIBarButtonItem(image: UIImage(named: "saveIcon"), style: .Plain, target: self, action: "save:")
saveBarButton.tintColor = colorGreyDark
}
//save function called when press saveBarButton
func save(sender: UIBarButtonItem) {
//save image
deselectShape()
let window: UIWindow! = UIApplication.sharedApplication().keyWindow
let windowImage = capture(window)
UIImageWriteToSavedPhotosAlbum(windowImage
, nil, nil, nil)
//Change saveBarButton …Run Code Online (Sandbox Code Playgroud) 我怀疑我的一些问题正在发生b/c我把所有的功能都放进去了$(document).ready().如果有人可以输入我应该使用的jQuery代码,我将非常感激!
只有第一个添加按钮有效.
删除按钮
其他添加的行删除按钮仅在将鼠标悬停在第一个项目符号上时显示.
删除按钮仅适用一次.删除一行后,删除按钮和添加按钮将失去其功能.删除和添加按钮也不会消失.
HMTL
这是我要添加的行
<div class="row">
<div class="col-lg-7">
<div class="form-group">
<div class="input-group input-group-lg">
<div class="input-group-btn">
<button type="button" class="btn btn-default button-remove" aria-label="Remove">
<span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span>
</button>
<button type="button" class="btn btn-default button-bullet" aria-label="Bullet">
<span class="glyphicon glyphicon-one-fine-dot" aria-hidden="true"></span>
</button>
</div>
<input type="text" name="Worksheet-Problem" class="form-control" placeholder="Problem..." aria-label="Write worksheet problem here">
<div class="input-group-btn">
<button type="button" class="btn btn-default button-add" aria-label="Add">
<span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
</button>
</div>
</div>
</div>
</div>
</div> …Run Code Online (Sandbox Code Playgroud) 正如你所看到的,#Demo-Card即使我设置了它,右边还有这个讨厌的白色空间body{padding: 0; margin: 0;}.
我也尝试过:
#Demo-Card {
padding: 0;
margin: 0;
}
Run Code Online (Sandbox Code Playgroud)
但那没用.
如何摆脱这个讨厌的白色空间?
如果有人可以提供帮助,我们将不胜感激!
HTML
<body>
<div id="Demo-Card">
<header>
<h3><span class="problem-number">11</span> <span class="problem-equation">Problem</span></h3>
</header>
<!--<button id="Run">Run Demo</button>-->
<div class="iframe-container">
<iframe id="Demo-iFrame" src="mathsynthesis/LearningByExample/GUI/web/mathsynth.html">
<p>Your browswer does not support iFrames</p>
</iframe>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
CSS
body{
padding: 0;
margin: 0;
font-family: 'Work Sans', sans-serif;
}
/*DEMO-CARD FORMATTING*/
#Demo-Card {
width: calc(100vw - 40px);
height: calc(100vh - 40px - 50px); /*40px for borders, 50px for …Run Code Online (Sandbox Code Playgroud) 如下图所示,我的footerImage页脚div的背景图像没有显示,即使div有一个明确定义的高度(50px)和宽度(100%),如绿色边框所示.为什么?我该如何解决?
注意:这不是图像路径问题,因为我可以在Brackets中提取图像的预览.
HTML:
<ul>
<li>
<a href="" target="_blank"> <figure>
<div class = "footerImage resume"> </div>
<figcaption>Resume</figcaption>
</figure></a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
CSS:
.footerImage {
background-repeat: no-repeat;
background-size: contain;
background-position: center center;
width: 100%;
height: 50px;
border: 1px solid green;
}
.footerImage .resume {
background-image: url('../images/resume.png');
}
Run Code Online (Sandbox Code Playgroud) 出于某种原因,Xcode认为我没有实现协议的didFailWithError方法CLLocationManagerDelegate
我没有看到我做错了什么,因为我从另一个SO帖子中复制了一下,说这个didFailWithError方法是为Swift 3更新的.所以我不明白为什么Xcode认为我没有实现didFailWithError
任何见解将不胜感激!
class OptionsViewController: UIViewController,
CLLocationManagerDelegate {
var locationManager: CLLocationManager = CLLocationManager()
override func viewDidLoad() {
//Ask user for location
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
//Use users current location if no starting point set
if CLLocationManager.locationServicesEnabled() {
if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedWhenInUse
|| CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedAlways {
locationManager.requestLocation()
}
else{
locationManager.requestWhenInUseAuthorization()
}
}
else{
//Alert user to open location service, bra bra bra here...
}
}
func locationManager(_ manager: …Run Code Online (Sandbox Code Playgroud) 我已经成功下载了该文件,但我无法保存该文件.因为我不断收到错误:
[SSZipArchive] Error: You don’t have permission to save the file “fileName” in the folder “Folder_Name”.
[SSZipArchive] Error: You don’t have permission to save the file “fileName” in the folder “__MACOSX”.
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
解压缩文件函数调用
ZipManager.unzipFile(atPath: filePath, delegate: self)
Run Code Online (Sandbox Code Playgroud)
ZipManager.swift
private static let documentsURL: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
static func unzipFile(atPath path: String, delegate: SSZipArchiveDelegate)
{
let destFolder = "/Folder_Name"
let destPath = documentsURL.appendingPathComponent(destFolder, isDirectory: true)
let destString = destPath.absoluteString
if ( !FileManager.default.fileExists(atPath: destString) )
{
try! FileManager.default.createDirectory(at: destPath, …Run Code Online (Sandbox Code Playgroud) I'm using a Jupyter notebook, Python 3.5, and a virtual environment.
Within my virtual env I did:
(venv) > pip install BeautifulSoup4
Run Code Online (Sandbox Code Playgroud)
Which seemed to run fine b/c the terminal output was:
Downloading beautifulsoup4-4.6.0-py2-none-any.whl (86kB)
100% |????????????????????????????????| 92kB 297kB/s
Installing collected packages: BeautifulSoup4
Successfully installed BeautifulSoup4-4.6.0
Run Code Online (Sandbox Code Playgroud)
But when I run my Jupyter notebook I get:
ImportError Traceback (most recent call last)
<ipython-input-1-5fe69888b1a1> in <module>()
5 from itertools import groupby
6 import pickle
----> 7 import bs4
8 import matplotlib.pyplot as …Run Code Online (Sandbox Code Playgroud) 空格是空格,制表符或换行符(即回车符或换行符)
我假设\s包括, \t,\n,\r,和\f
但是当我尝试使用\s它时,无法正确拆分字符串:
# let line1 = "We the People of the United States, in Order to form a more perfect";;
# let wsp_regex = Str.regexp "\\s+";;
# let words = Str.split wsp_regex line1;;
val words : string list =
["We the People of the United State"; ", in Order to form a more perfect"]
# let wsp_regex = Str.regexp "[ \\s]+";;
# let words = Str.split wsp_regex …Run Code Online (Sandbox Code Playgroud) ios ×4
html ×3
swift ×3
css ×2
calayer ×1
javascript ×1
jquery ×1
ocaml ×1
python ×1
python-3.5 ×1
regex ×1
ssziparchive ×1
string ×1
swift3 ×1
uiview ×1
virtualenv ×1
xcode ×1