小编Bea*_*wah的帖子

用Swift实现UITextFieldDelegate

我有我的ViewController类,它实现了UITextFieldDelegate.我没有像textFieldShouldBeginEditing这样的func自动完成.这是XCode 6中的错误吗?这是我的类实现.

class ViewController: UIViewController, UITextFieldDelegate
Run Code Online (Sandbox Code Playgroud)

delegates ios swift

22
推荐指数
6
解决办法
8万
查看次数

使用Swift处理Objective-C块

我在新的Swift项目中使用Objective-C Firebase框架时遇到了麻烦.我来自大多数C#背景,所以Swift闭包语法还不是很清楚.

以下是代码在Objective-C中的工作方式,其中f是Firebase对象

[f observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
  NSLog(@"%@ -> %@", snapshot.name, snapshot.value);
}];
Run Code Online (Sandbox Code Playgroud)

XCode自动建议这种语法,我还没有找到一个有效的解决方案.

f.observeEventType(FEventTypeValue, withBlock: ((FDataSnapshot!) -> Void)?)
Run Code Online (Sandbox Code Playgroud)

我想像在Objective-C示例中那样将FDataSnapshot数据分配给变量.谢谢

closures objective-c swift

11
推荐指数
1
解决办法
7307
查看次数

iPhone应用程序崩溃[self.tableView endUpdates]

我的表视图显示了用户列表.添加用户后,我在刷新表格视图时遇到问题.我尝试过不同的代码和事件组合,现在应用程序在endUpdates调用时崩溃了.该应用程序是在配方应用程序之后建模的,因此用户单击添加按钮,然后会出现一个模态窗口,询问用户名称.然后它进入编辑屏幕,然后返回用户列表.此时,新用户没有显示出来.但是,如果我导航回主屏幕,然后返回用户屏幕,则会出现用户.

这是我的一些代码:

    - (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
    sectionInsertCount = 0;
    [self.tableView beginUpdates];
}
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
  [self.tableView endUpdates];

}

    - (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
 switch(type) {

  case NSFetchedResultsChangeInsert:
            if (!((sectionIndex == 0) && ([self.tableView numberOfSections] == 1))) {
                [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
                sectionInsertCount++;
            }

   break;
  case NSFetchedResultsChangeDelete:
            if (!((sectionIndex == 0) && ([self.tableView numberOfSections] == 1) )) {
                [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
                sectionInsertCount--;
            }

   break;
        case NSFetchedResultsChangeMove:
            break;
        case NSFetchedResultsChangeUpdate: 
            break;
        default:
            break;
 }
}

    - (void)controller:(NSFetchedResultsController …
Run Code Online (Sandbox Code Playgroud)

iphone core-data uitableview

9
推荐指数
2
解决办法
7829
查看次数

SQL CE 4.0作为InstallShield先决条件

我正在制作自己的prq文件,以便在安装WPF应用程序的情况下执行SQL CE 4.0安装.安装程序一直在失败,我不知道为什么.看起来它试图运行CE exe,但随后Windows Installer帮助窗口会出现所有这些命令行帮助选项.我单击确定,然后它说CE的安装失败.我不知道如何确定出了什么问题.

这是我的prq文件内容:

<?xml version="1.0" encoding="UTF-8"?>
<SetupPrereq>
<conditions>
    <condition Type="32" Comparison="2" Path="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v4.0\ENU" FileName="DesktopRuntimeVersion" ReturnValue="4.0.8482.1"></condition>
</conditions>
<files>
    <file LocalFile="&lt;ISProductFolder&gt;\SetupPrerequisites\SSCERuntime_x86-ENU.exe" URL="http://www.microsoft.com/download/en/details.aspx?id=17876" FileSize="0,0"></file>
</files>
<execute file="SSCERuntime_x86-ENU.exe" cmdline="/passive /norestart" cmdlinesilent="/passive /norestart"></execute>
<properties Id="{F7BF54C1-CA2C-4410-98DB-480769CE6547}" Description="This prerequisite installs the Microsoft SQL Server Compact 4.0."></properties>
</SetupPrereq>
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激.

windows-installer installshield sql-server-ce

8
推荐指数
1
解决办法
7153
查看次数

使用Angular 2路由器拦截路由请求

使用Angular 2路由器,我想在请求激活路由时捕获事件.在Angular 1.x中,我使用$ locationChangeSuccess,然后检查用户是否已登录.

我需要使用Angular 2做类似的事情,因此如果用户尚未通过身份验证,我可以将用户重定向到登录屏幕.

javascript angular2-routing angular

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

hapi.js版本18.x打字

我最近将项目升级为使用@hapi/hapi节点模块与旧hapi模块。我正在使用版本18.3.1("@hapi/hapi": "^18.3.1")。

随着导入读取,我的打字稿定义不再起作用: import * as Hapi from 'hapi';

运行节点进程时,出现模块未找到错误。有没有办法将类型指向@types/hapi@hapi/hapi模块?

node.js typescript hapijs

2
推荐指数
1
解决办法
605
查看次数