我刚刚开始使用xCode 6,我似乎无法弄清楚如何将新的swift文件添加到我在界面构建器中添加的新视图控制器中.
任何有关如何进行的提示将不胜感激.
我有一个按字母顺序排序的名称列表,现在我想在表格视图中显示这些名称.我正在努力为每个字母分组这些名字.
我的代码看起来像这样:
let sections:Array<AnyObject> = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
var usernames = [String]()
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cellID = "cell"
let cell: UITableViewCell = self.tv.dequeueReusableCellWithIdentifier(cellID) as UITableViewCell
cell.textLabel?.text = usernames[indexPath.row]
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return usernames.count
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int{
return 26
}
func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]!{
return self.sections
}
func tableView(tableView: UITableView,
sectionForSectionIndexTitle title: String,
atIndex index: Int) -> Int{
return index
}
func tableView(tableView: UITableView,
titleForHeaderInSection …Run Code Online (Sandbox Code Playgroud) 我需要在我的累积Nvd3图表中添加多个y轴,是否有人知道我需要修改的库代码的哪一部分?
如果你自己做了这件事并且可以提供一个Jsfiddle,那就更好了.
任何建议,将不胜感激.
javascript d3.js nvd3.js angularjs-nvd3-directives angular-nvd3
我正在尝试使用FileSaver.js下载从我的快递应用程序提供的PNG文件.这些文件是作为base64编码的字符串发送的,但是当我尝试使用FileSaver.js保存它们时,它们就会被破坏.
这是我试图保存它们的方式:
var blob = new Blob([base64encodedString], {type: "data:image/png;base64"});
saveAs(blob, "image.png");
Run Code Online (Sandbox Code Playgroud)
我也使用了这种保存图像的方法,但是如果base64encodedString变得太大,它就不起作用:
var download = document.createElement('a');
download.href = 'data:image/png;base64,' + base64encodedString;
download.download = 'reddot.png';
download.click();
Run Code Online (Sandbox Code Playgroud)
我在FileSaver.js上做错了什么?
我正在尝试在 Keycloak 中创建基于 JS 的策略,文档指出:
要创建新的基于 JavaScript 的策略,请在策略列表右上角的下拉列表中选择 JavaScript。
但是当我点击MyClient->Authorization->Policies右上角CreatePolicy的下拉菜单时,没有“基于 JS 的策略”替代方案。
我在这里错过了什么吗?列表中唯一的策略是 whichDefault Policy类型为js,这也让我感到困惑,因为这意味着基于 JS 的策略应该可用。
我正在运行 Keycloak 10.0.0,但我也尝试过版本9.0.3
我正在尝试将一个简单的popoverController添加到我的iphone应用程序中,而我正在努力使用经典的"空白屏幕",当我点击按钮时,它会覆盖所有内容.
我的代码看起来像这样:
@IBAction func sendTapped(sender: UIBarButtonItem) {
var popView = PopViewController(nibName: "PopView", bundle: nil)
var popController = UIPopoverController(contentViewController: popView)
popController.popoverContentSize = CGSize(width: 3, height: 3)
popController.presentPopoverFromBarButtonItem(sendTappedOutl, permittedArrowDirections: UIPopoverArrowDirection.Up, animated: true)
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController!) -> UIModalPresentationStyle {
// Return no adaptive presentation style, use default presentation behaviour
return .None
}
}
Run Code Online (Sandbox Code Playgroud)
该adaptivePresentationStyleForPresentationController功能只是一些我加入,因为我读的地方,这是你需要实现以获得在iPhone上这个功能是什么.但仍然:整个屏幕上仍然有一个空白图像,我不知道如何修复它.
任何建议,将不胜感激.
我想保存,然后检索我保存到我的tmp文件夹的图像,这是我第一次使用文件系统,所以如果我没希望,请耐心等待.
现在,我正在保存正在检索的图像,如下所示:
let userImageFile = object["Image"] as PFFile
userImageFile.getDataInBackgroundWithBlock { (imageData: NSData!, error: NSError!) -> Void in
if error == nil {
image = UIImage(data:imageData)
let imageToSave:NSData = UIImagePNGRepresentation(image)
let path = NSTemporaryDirectory() + "MyFile"
imageToSave.writeToFile(path, atomically: true)
}
}
Run Code Online (Sandbox Code Playgroud)
假设这是保存它的正确方法我还想检索图像.如何创建对要检索的文件的引用.我之前只使用过userDefaults,你在那里为你要保存的文件添加一个名字,我看不到你在保存到tmp文件夹时怎么做.
任何有关如何解决这个问题的建议将不胜感激.
我正在尝试使用Tkinter创建一个视图,因此我也在使用pylab.我的问题是我得到一个错误说:
AttributeError:'module'对象没有属性'Figure'
并且错误来自这行代码:
self.fig = FigureCanvasTkAgg(pylab.figure(), master=self)
Run Code Online (Sandbox Code Playgroud)
我是python的新手,所以我不知道如何解决这个问题,因为它figure()应该是pylab库的一部分.
任何有关如何解决这个问题的建议将不胜感激.
编辑:
这是完整的代码:
from Tkinter import *
import ttk
from ttk import Style
import pylab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib.pyplot as plt
from numpy import cumsum
import matplotlib
class GUI(Frame):
def __init__(self, parent, motspiller):
Frame.__init__(self, parent)
self.style = Style()
self.fig = None
def setup(self):
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
label = Label(self.parent)
label.place(x=800, y=50)
quit_button = Button(self, text="Quit", command=self.quit)
quit_button.place(x=1000, y=450)
self.fig = FigureCanvasTkAgg(pylab.figure(), master=self)
self.fig.get_tk_widget().grid(column=0, row=0)
self.fig.show()
Run Code Online (Sandbox Code Playgroud) 经过与Twitters typeahead.js的长期斗争之后,我终于可以决定将哪个模板用于我的建议.
但是,虽然这似乎是一个简单的过程,但我收到以下错误:
未捕获的TypeError:g.templates.suggestion不是函数
我的代码看起来像这样
HTML:
<input id = "search" type="text" placeholder="Colors">
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
var colors = ["red", "blue", "green", "yellow", "brown", "black"];
var colorsource = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
// `states` is an array of state names defined in "The Basics"
local: colors
});
$('#search').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'color',
source: colorsource,
templates: {
empty: [
'<div class="empty-message">',
'unable to find any Best Picture winners that match the current query',
'</div>'
].join('\n'),
suggestion: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 AWS-cli 使用以下命令将 MFA 删除添加到我的 S3 存储桶中:
aws s3api put-bucket-versioning --bucket <my-bucket-name> --versioning-configuration '{"MFADelete":"Enabled","Status":"Enabled"}' --mfa 'arn:aws:iam::<code-found-at-iam-page>:mfa/root-account-mfa-device <my-google-authenticator-code>'
Run Code Online (Sandbox Code Playgroud)
但我得到的回应是这样的:
调用 PutBucketVersioning 操作时出现错误(InvalidRequest):DevPay 和 Mfa 是互斥的授权方法。
这毫无意义,因为我从未使用过 DevPay。我的实例安全组启用了 S3FullAccess,因此这也不成问题。
任何关于问题可能是什么的建议将不胜感激。
swift ×4
ios ×3
javascript ×3
amazon-s3 ×1
angular-nvd3 ×1
angularjs ×1
blob ×1
d3.js ×1
filesaver.js ×1
jquery ×1
keycloak ×1
matplotlib ×1
nsarray ×1
nvd3.js ×1
python ×1
tkinter ×1
tmp ×1
typeahead.js ×1
uitableview ×1
xcode6 ×1