我正在使用带有Swift 3的iOS图表.
我有100 x 100 PieChartView渲染饼图,但它没有填充视图(NSView确切地说是一个).灰色框是视图,饼图和边缘之间有很大的间隙.
我已确认视图为100 x 100:
print(graph.frame) //<-- (25.0, 65.0, 100.0, 100.0)
Run Code Online (Sandbox Code Playgroud)
所以我假设我需要在饼图中配置一些东西,以使其成为视图中的完整大小.这是我到目前为止所尝试的无济于事:
graph.holeRadiusPercent = 0.7
graph.transparentCircleRadiusPercent = 0
graph.legend.enabled = false
graph.chartDescription?.enabled = false
graph.minOffset = 0
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
Xcode 9.1,Swift 4
我正在尝试创建一个NSTextField随着用户输入文本而增长的高度.就像在Mac上的iMessage中那样.这是一个视频示例:http://d.pr/v/zWRA6w
我已经设置了NSViews这样的设置,以便我可以在周围设置自定义设计,NSTextField并保持默认边框和背景关闭:
我试着按照这个答案创建了以下Swift版本:
class ResizingTextField: NSTextField{
var isEditing = false
override func textDidBeginEditing(_ notification: Notification) {
super.textDidBeginEditing(notification)
isEditing = true
}
override func textDidEndEditing(_ notification: Notification) {
super.textDidEndEditing(notification)
isEditing = false
}
override func textDidChange(_ notification: Notification) {
super.textDidChange(notification)
self.invalidateIntrinsicContentSize()
}
override public var intrinsicContentSize: CGSize {
if isEditing{
let fieldEditor = self.window?.fieldEditor(false, for: self)
if fieldEditor != nil{
if let cellCopy = self.cell?.copy() as? …Run Code Online (Sandbox Code Playgroud) 我已经阅读了许多与此相关的答案,但我仍然无法让它发挥作用.
我有一个用户可以在其中签名的视图.以下是它的外观:http://d.pr/i/McuE
我可以成功检索此图像并将其保存到文件系统,但我需要在保存前将其旋转90度,以便签名从左到右读取.
// Grab the image
UIGraphicsBeginImageContext(self.signArea.bounds.size);
[self.signArea drawRect: self.signArea.bounds];
UIImage *signatureImage = UIGraphicsGetImageFromCurrentImageContext();
//-- ? -- Rotate the image (this doesn't work) -- ? --
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextRotateCTM(context, M_PI_2);
UIGraphicsEndImageContext();
//Save the image as a PNG in Documents folder
[UIImagePNGRepresentation(signatureImage) writeToFile:[[PPHelpers documentsPath] stringByAppendingPathComponent:@"signature-temp.png"] atomically:YES];
Run Code Online (Sandbox Code Playgroud)
如何在保存之前旋转图像?
在此先感谢您的帮助.我使用iOS 7 SDK在Xcode 5上.
我希望能够从而http://pbdev不是访问我的 Vue 项目localhost:8080。我熟悉在 Apache 中创建虚拟主机,但我不清楚如何使用 Vue CLI 3 项目来创建虚拟主机。
到目前为止,我已将其放入/etc/hosts:
# Vue Hosts
127.0.0.1:8080 pbdev
Run Code Online (Sandbox Code Playgroud)
我把这个放进去vue.config.js:
module.exports = {
lintOnSave: false,
devServer: {
host: 'pbdev',
port: 8080,
https: false
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
INFO Starting development server...
10% building modules 1/1 modules 0 activeevents.js:167
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND pbdev
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
Emitted 'error' event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1505:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] …Run Code Online (Sandbox Code Playgroud) 我目前hooks.ts在 SvelteKit 应用程序的文件中使用以下内容:
export async function handle({ event, resolve }) {
console.log(event.locals) //<-- Works fine
}
Run Code Online (Sandbox Code Playgroud)
我试图弄清楚如何在event和resolve参数上使用类型。据我所知,event工作原理如下:
import type { RequestEvent } from '@sveltejs/kit'
export async function handle(event: RequestEvent, resolve: ???){
...
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何输入参数resolve。这里的文档显示了这一点:
export async function handle({ event, resolve }) {
console.log(event.locals) //<-- Works fine
}
Run Code Online (Sandbox Code Playgroud)
从我有限的 TypeScript 知识来看,它看起来像是resolve一个带有两个返回 Promise 的参数的函数。但是我如何在函数声明中写出它呢handle?
我是GetX的新手,正在尝试学习如何使用它。我读过不同的教程,这些教程将控制器注入到小部件的方法之外build,还有其他教程将其放入其中。
class MyWidget extends StatelessWidget{
const MyWidget({Key? key}) : super(key:key);
//Outside...
final controller = Get.put(Controller()); //<---
@override
Widget build(BuildContext context) {
//Inside...
final controller = Get.put(Controller()); //<---
return Obx(
() => Text(controller.name)
);
}
}
Run Code Online (Sandbox Code Playgroud)
这两个地点有区别吗?如果是这样,为什么?
另外,它应该放在哪里StatefulWidget?看来它不应该进入build方法内部,因为它会给我带来堆栈溢出错误。
Get.put()小部件内的位置是否重要?
我遇到了一些问题 22. 我正在使用 FMDB 的奇特withParameterDictionary方法将数据插入到我的 SQLite 数据库中,如下所示:
NSDictionary *aircraftDict = [NSDictionary dictionaryWithObjectsAndKeys:
self.aircraftIdTextField.text, @"aircraft_id",
self.makeModelTextField.text, @"make_model",
self.categoryClassTextField.text, @"category_class",
@YES, @"updated_flag",
nil];
NSString *addAircraftQuery = @"INSERT INTO aircrafts (aircraft_id, make_model, category_class, updated_flag) VALUES (:aircraft_id, :make_model, :category_class, :updated_flag)";
[db executeUpdate:addAircraftQuery withParameterDictionary:aircraftDict];
Run Code Online (Sandbox Code Playgroud)
问题在于,当这些文本字段之一为空时,它会截断 NSDictionary,因为一个nil值告诉字典它已到达其值列表的末尾。
通过确保字典中的每个值都有一个空白对象(例如像 string @""),我可以很好地解决这个问题。
但是随后我的值作为“空白”值而不是NULL. 这可能没什么大不了的,但我听说 usingNULL会占用更少的数据库空间。
如何NULL在不过早地截断 NSDictionary 的情况下插入到我的数据库中?
我有一个Swift应用程序,它使用在Linux服务器上远程运行的Realm Object Server.一切正常,包括实时同步.
偶尔我想检查iOS模拟器使用的本地Realm文件的内容,以便我可以进行一些调试.当我在这里浏览时:
~/.../CoreSimulator/.../Documents/realm-object-server/<unique id>/
Run Code Online (Sandbox Code Playgroud)
...然后我尝试打开这个文件: realm%3A%2F%2F104%2E236%2E129%2E235%3A9080%2F%7E%2Fmyapp.realm
我收到提示:请输入此Realm文件的有效加密密钥.
我从哪里获得此加密密钥?我尝试使用来自服务器的管理员令牌,但这似乎不起作用.
另外,我可以在任何地方关闭加密吗?或者对于使用Realm Object Server的任何应用程序是强制性的吗?
Xcode 8.2.1,Swift 3.0.2,macOS 10.12
我有一个NSSplitViewController有3个窗格(请注意NS;这是一个Mac应用程序).
我正在尝试将最左侧的窗格设置为始终具有固定宽度,而不是可调整大小.我尝试过以下方法:
constrainMaxCoordinate并constrainMinCoordinate没有奏效.有没有其他人最近上班?有很多关于这个主题的文章,但他们的工具集已有几年的历史了,他们的建议都没有对我有用.谢谢!
我正在研究 Apple 的CloudKit Catalog 示例,我只是想让身份验证正常工作。我想在浏览器窗口(而不是 Node JS)中运行此 JS 代码。我从他们的网站上获取了他们的代码,如下所示:
\n\n<!DOCTYPE html>\n<html lang="en">\n <head></head>\n <body>\n <script>\n window.addEventListener(\'cloudkitloaded\', function() {\n\n CloudKit.configure({\n containers: [{\n containerIdentifier: \'iCloud.com.example.CloudKitCatalog\',\n apiToken: \'b86f0b5db29f04f45badba0366f39b7130a505f07765b5ba3a2ceb0cb3d96c0c\',\n persist: true,\n environment: \'production\',\n signInButton: { id: \'sign-in-button\', theme: \'black\' },\n signOutButton: { id: \'sign-out-button\', theme: \'black\' }\n }]\n })\n\n var container = CloudKit.getDefaultContainer()\n\n //-----\n function gotoAuthenticatedState(userIdentity) {\n var name = userIdentity.nameComponents\n if(name) {\n displayUserName(name.givenName + \' \' + name.familyName)\n } else {\n displayUserName(\'User record name: \' + userIdentity.userRecordName)\n }\n container\n .whenUserSignsOut()\n …Run Code Online (Sandbox Code Playgroud) ios ×2
autolayout ×1
cloudkit ×1
cloudkit-js ×1
cocoa ×1
dart ×1
flutter ×1
flutter-getx ×1
fmdb ×1
ios-charts ×1
javascript ×1
macos ×1
nssplitview ×1
nstextfield ×1
nsview ×1
objective-c ×1
realm ×1
sqlite ×1
svelte ×1
sveltekit ×1
swift ×1
typescript ×1
uiimage ×1
vue-cli ×1
vue-cli-3 ×1
vue.js ×1
webpack ×1