小编Dan*_*evy的帖子

Xcode 7到Xco​​de 8 Storyboard约束警告

我刚刚将Xcode项目从Xcode 7.3转换为Xcode 8 GM,我收到了超过80个约束警告.在Xcode 7中,我的故事板是"大方块"而不是特定的iPhone大小.现在,使用Xcode 8,您可以更改为不同的iPhone和iPad尺寸.我的约束仍然出现,因为它们与Xcode 7中更平方的VC有关.是否有"快速"修复或者我是否需要通过我的整个应用并修复每个约束(远远超过80)?

更新:2016年9月20日 - >根据 Feed 提交了许多错误报告,Apple应该知道这个问题.一旦问题得到解决,我将立即更新答案.

xcode uiviewcontroller ios uistoryboard xcode8

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

"错误"类型的值没有成员"代码"

我在移动测试应用程序的Xcode 8 Beta中5和转换我的代码斯威夫特3.我离开了我与有关开关的一些错误ErrorNSError.我在Xcode中得到一个错误,'Value of type 'Error' has no member 'code'.我仍然可以使用localizedDescription.是code不再内的值Error或者是它只是一个错误在Xcode?

nserror ios swift swift3 xcode8

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

使用 Jest 进行测试时如何使用 `import.meta`

我正在使用 ESModules 编写 Node.js 代码(在 TypeScript 中),我需要访问__dirname. 为了访问等效__dirname于 CommonJS 中的 ESM ,我调用dirname(fileURLToPath(import.meta.url)). 我也在用 TypeScript 在 Jest 中编写测试。使用指南,我设置了 Babel。当我运行jest命令时,我得到

const DIRNAME = (0, _path.dirname)((0, _url.fileURLToPath)(import.meta.url));
                                                                      ^^^^
SyntaxError: Cannot use 'import.meta' outside a module
Run Code Online (Sandbox Code Playgroud)

这是我写的文件

someCode.ts

import { dirname } from "path";
import { fileURLToPath } from "url";

const DIRNAME = dirname(fileURLToPath(import.meta.url));

export const x = 5;
Run Code Online (Sandbox Code Playgroud)

someCode.test.ts

import { x } from "./someCode";

it("Returns 5 as the result", () …
Run Code Online (Sandbox Code Playgroud)

typescript jestjs babeljs

19
推荐指数
3
解决办法
3423
查看次数

当UITextView的文本超出1行时,展开UITextView和UITableView

我有一个UITableView,每个单元格内有两个UITextViews.我希望UITableViewCell和UITextView的高度都增加,这样用户就不需要在UITextView中滚动了.这是我尝试过的:

在TableViewController类中:

    self.tableView.estimatedRowHeight = 44
    self.tableView.rowHeight = UITableViewAutomaticDimension
Run Code Online (Sandbox Code Playgroud)

在TableViewCell类中(从这里得到):

func textViewDidChange(textView: UITextView) {

    var frame : CGRect = textView.frame
    frame.size.height = textView.contentSize.height
    textView.frame = frame
}
Run Code Online (Sandbox Code Playgroud)

当用户输入超出UITextView的设置宽度时,UITableView将高度从44增加到大约100,UITextView的高度不会增加.我设置了约束,以便UITextView的高度等于UITableViewCell的高度.

任何想法为什么会发生这种情况以及如何正确地动态更改UITextView和UITableView的高度?

uitableview uitextview ios swift

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

Firebase提供商数据

我正在尝试获取Firebase用户的提供商信息(电子邮件,Facebook,Twitter等).当我运行时FIRAuth.auth()?.currentUser.providerID,Firebase即使用户在Twitter上注册,我也会得到并输出.当我跑步时,FIRAuth.auth()?.currentUser.providerData我得到了[<FIRUserInfoImpl: 0x7a63e7f0>].我如何获得的输出FacebookTwitter

xcode firebase swift firebase-authentication

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

带有childKey的Firebase queryEqualToValue

我正在尝试使用以下方法查询Firebase数据库中的数据:

queryEqual(toValue: Any?, childKey: String?)
Run Code Online (Sandbox Code Playgroud)

我的数据库结构:

Schools {
    testUID1 {
        schoolNameLC: test school 1
    }
}
Run Code Online (Sandbox Code Playgroud)

我的查询是:

databaseReference.child("Schools").queryEqual(toValue: "test school 1", childKey: "schoolNameLC").observe(.value) { (snap) in
        print(snap)
    }
Run Code Online (Sandbox Code Playgroud)

这个查询打印出来null,我不能让它工作.由于我的应用程序的设置方式,我不知道该键在父键下schoolNameLC有一个值.我想要做的就是在我的数据库中搜索并返回值为的任何内容.testSchool1testUID1SchoolsschoolNameLCtest school 1

ios firebase swift firebase-realtime-database

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

如何用 Jest 模拟 fs.promises.writeFile

我正在尝试模拟使用 Jest的promise版本fs.writeFile,并且没有调用被模拟的函数。

要测试的功能(createFile.js)

const { writeFile } = require("fs").promises;

const createNewFile = async () => {
    await writeFile(`${__dirname}/newFile.txt`, "Test content");
};

module.exports = {
    createNewFile,
};
Run Code Online (Sandbox Code Playgroud)

玩笑测试(createFile.test.js):

const fs = require("fs").promises;
const { createNewFile } = require("./createFile.js");

it("Calls writeFile", async () => {
    const writeFileSpy = jest.spyOn(fs, "writeFile");

    await createNewFile();
    expect(writeFileSpy).toHaveBeenCalledTimes(1);

    writeFileSpy.mockClear();
});
Run Code Online (Sandbox Code Playgroud)

我知道writeFile实际上正在调用它,因为我运行node -e "require(\"./createFile.js\").createNewFile()"并创建了文件。

依赖版本

  • Node.js:14.1.0
  • 开玩笑:26.6.3

-- 这是对createFile.test.js文件的另一次尝试--

const fs = require("fs");
const …
Run Code Online (Sandbox Code Playgroud)

mocking spy fs node.js jestjs

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

将自定义属性添加到Firebase身份验证

我已经通过Firebase的文档进行了搜索,似乎找不到向FIRAuth添加自定义属性的方法.我正在从Parse-Server迁移应用程序,我知道我可以设置用户的用户名,电子邮件和objectId.不,我看到我可以选择电子邮件,displayName和photoURL.我希望能够添加自定义属性,如用户名.例如,我可以使用:

let user = FIRAuth.auth()?.currentUser
            if let user = user {
                let changeRequest = user.profileChangeRequest()

                changeRequest.displayName = "Jane Q. User"
                changeRequest.photoURL =
                    NSURL(string: "https://example.com/jane-q-user/profile.jpg")
                changeRequest.setValue("Test1Name", forKey: "usersName")
                changeRequest.commitChangesWithCompletion { error in
                    if error != nil {

                        print("\(error!.code): \(error!.localizedDescription)")

                    } else {

                        print("User's Display Name: \(user.displayName!)")
                        print("User's Name: \(user.valueForKey("name"))")

                    }
                }
            }
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,我收到"usersName"不符合键值的错误.这不是正确的代码.我似乎无法找到另一种方式.

database xcode firebase swift firebase-authentication

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

使用Firebase 3和Swift记录用户仍会显示`currentUser`

我想在我的iOS应用程序中使用Firebase 3登录用户.这是我的代码:

do {

        databaseReference.child("Users").child(CUUID!).removeAllObservers()

        try FIRAuth.auth()?.signOut()

        print("FIRUSER - \(FIRAuth.auth()?.currentUser)")

        self.performSegueWithIdentifier("logOutSegue", sender: self)

    } catch let logOutError {

        print("Error Logging User Out - \(logOutError)")
    }
Run Code Online (Sandbox Code Playgroud)

我想要做的是如果用户成功注销,则执行segue返回登录屏幕.为了检查用户是否已注销,我打印currentUser以查看是否还有用户.我按下logOut按钮并且segue工作(没有捕获 - >没有错误),但是当print("FIRUSER - \(FIRAuth.auth()?.currentUser)")代码运行时,我仍然得到一个currentUser.为什么用户没有注销?

xcode ios firebase swift firebase-authentication

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

从Firebase数据库中删除值

我正在尝试删除Firebase实时数据库中的值.这是我正在使用的代码:

FIRDatabase.database().reference()
           .child(FIRAuth.auth()!.currentUser!.uid).child("instagramLink")
           .removeValue()
Run Code Online (Sandbox Code Playgroud)

这是JSON数据结构:

Users {

    userUID {

        email: "test@test.com"
        fullName: "John Doe"
        instagramLink: "testLink"
    }
}
Run Code Online (Sandbox Code Playgroud)

我告诉数据库删除密钥"instagramLink",我知道它目前在数据库中,但密钥永远不会被删除.

如何删除密钥?

ios firebase swift firebase-realtime-database

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

在UITableView HeaderView中检测UISegmentedControl中的更改

我试图控制我的UITableView基础上selectedSegmentIndexUISegmentedControl我的UITableView水箱内.从本质上讲,我希望这UISegmentedControl可以像推特的"我"标签一样工作.我有UISegmentedControl一个UITableView标题内部,它使用此方法出列:

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    let cell = tableView.dequeueReusableCell(withIdentifier: "sectionDetailsHeaderView") as! SectionDetailsHeaderTableViewCell
    return cell
}
Run Code Online (Sandbox Code Playgroud)

我有一个连接到UISegmentedControl的插座SectionDetailsHeaderTableViewCell,但我无法弄清楚如何检测UISegmentedControl中的更改.我想设置一个变量,var segmentedControlValue = Int()selectedSegmentIndex每一次的修改,然后调用一个函数,func chooseDataToDisplay() {}该值改变时.我该怎么做呢?

uitableview uisegmentedcontrol ios swift uitableviewsectionheader

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

核心数据NSManagedObject没有有效的NSEntityDescription

我正在尝试使用我的Xcode项目设置核心数据并遇到一个我似乎无法摆脱的错误.我有一个叫做UserDetails里面的实体StudyHub.xcdatamodeld.我在AppDelegate中的代码:

// MARK: - Core Data stack

lazy var persistentContainer: NSPersistentContainer = {
    /*
     The persistent container for the application. This implementation
     creates and returns a container, having loaded the store for the
     application to it. This property is optional since there are legitimate
     error conditions that could cause the creation of the store to fail.
     */
    let container = NSPersistentContainer(name: "DELETE")
    container.loadPersistentStores(completionHandler: { (storeDescription, error) in
        if let error = error as NSError? {
            // …
Run Code Online (Sandbox Code Playgroud)

xcode core-data ios appdelegate swift

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