小编Fab*_*oni的帖子

Bower呼叫被公司代理阻止

我正在尝试将Bower用于Web应用程序,但发现自己遇到了某种代理问题:

D:\>bower search jquery
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 1.2s
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 2.5s
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 6.8s
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 15.1s
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 20.3s
bower ECONNRESET    Request to https://bower.herokuapp.com/packages/search/jquery failed: tunneling socket could not be established, cause=Parse Error
Run Code Online (Sandbox Code Playgroud)

相关要点:

  • 我可以浏览到https://bower.herokuapp.com/packages/search/jquery并返回完整的json响应.
  • 我可以使用git来克隆,使用git://协议和http(s).
  • 我可以直接使用NPM而不会出现这些问题
  • 我已经尝试使用Fiddler来确定被阻止的内容,但它没有检测到Bower命令的任何调用.我可以在Fiddler看到来自NPM命令的调用. …

proxy bower

78
推荐指数
7
解决办法
8万
查看次数

如何在Swift中单元测试抛出函数?

如何测试Swift 2.0中的函数是否抛出?如何断言正确ErrorType抛出?

xcode unit-testing swift

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

UITextView在第一次单击时不显示InputAccessoryView

我使用UITextViewDelegate和添加InputAccessoryViewtextViewDidBeginEditing:

[textView setInputAccessoryView:doneBar];
Run Code Online (Sandbox Code Playgroud)

doneBar不是零,它出现在第二次打开时.

有没有其他人这个问题?

提前致谢.

iphone objective-c uitextview uitextviewdelegate

19
推荐指数
1
解决办法
8935
查看次数

获取UIBarButtonItem的宽度

我想要得到一个宽度UIBarButtonItem.

这不起作用:

barbuttonitem.customView.frame.size.width
Run Code Online (Sandbox Code Playgroud)

这也行不通:

barbuttonitem.width
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uibarbuttonitem

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

每次24小时风格的NSDate小时数?

我有这个日期格式化程序:

 NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
 [timeFormatter setDateFormat:@"HH:mm"];
Run Code Online (Sandbox Code Playgroud)

如果我用这个:

 NSDate *myDate = [timeFormatter dateFromString:@"13:00"];
Run Code Online (Sandbox Code Playgroud)

它返回:

 "1:00"
Run Code Online (Sandbox Code Playgroud)

这是因为模拟器已关闭24小时.但对于我的应用程序,我真的需要"13:00"而不是"1:00"

--- 编辑1 ---

添加了新代码:

NSCalendar *calendar= [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSCalendarUnit unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;

NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
[timeFormatter setDateFormat:@"HH:mm"];
NSDate *timeForFirstRow = [timeFormatter dateFromString:@"13:00"];
NSDateComponents *dateComponents = [calendar components:unitFlags fromDate:timeForFirstRow];
NSInteger hour = [dateComponents hour]; //This will be 1 instead of 13
NSInteger minute = [dateComponents minute];
Run Code Online (Sandbox Code Playgroud)

objective-c nsdateformatter ios

13
推荐指数
2
解决办法
7897
查看次数

NSAttributedString初始化抛出NSRangeException

我写了一个简单的扩展来解码html实体:

extension String {
    func htmlDecode() -> String {
        if let encodedData = self.data(using: String.Encoding.unicode) {
            let attributedString = try! NSAttributedString(data: encodedData, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.unicode], documentAttributes: nil)
            return attributedString.string
        }
        return self
    }
}
Run Code Online (Sandbox Code Playgroud)

现在它在行上抛出一个错误if let attributedString …:

***由于未捕获的异常'NSRangeException'终止应用程序,原因:'*** - [__ NSArrayM objectAtIndex:]:索引4超出边界[0 .. 2]'

self不是零什么的,只是一个String像这样的:

self = (String) "...über 25'000 Franken..."

这种奇怪的NSArray例外来自哪里?

nsattributedstring ios swift

9
推荐指数
1
解决办法
1166
查看次数

从UIWebView中检测window.open()

简短的问题:是否有可能window.open()UIWebView使用中检测到UIWebViewDelegate或是否有其他方法可以达到此目的?当window.open()-Event被激活以显示时,我需要url UIAlertView.

iphone objective-c uiwebview

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

如何检测正在WKWebView中播放的电影?

我想知道是否可以检测到在WKWebView中播放的电影?

另外,我想知道打开的流的确切URL?

ios swift wkwebview

8
推荐指数
2
解决办法
4108
查看次数

第一天!="本月的第一天"

使用"第一天"修改日期时,PHP中有一种非常奇怪的行为.

'first day' ' of'?设置当前月份的第一天.(http://php.net/manual/de/datetime.formats.relative.php)

$currentMonthDate = new DateTime("2014-07-30 10:26:00.000000");
echo $currentMonthDate->format('Ym');

$currentMonthDate->modify('first day');
echo $currentMonthDate->format('Ym');
Run Code Online (Sandbox Code Playgroud)

201407/201407 好的

$currentMonthDate = new DateTime("2014-07-31 10:26:00.000000");
echo $currentMonthDate->format('Ym');

$currentMonthDate->modify('first day');
echo $currentMonthDate->format('Ym');
Run Code Online (Sandbox Code Playgroud)

二十○万一千四百〇七/ 201408 为什么?

$currentMonthDate = new DateTime("2014-08-01 10:26:00.000000");
echo $currentMonthDate->format('Ym');

$currentMonthDate->modify('first day');
echo $currentMonthDate->format('Ym');
Run Code Online (Sandbox Code Playgroud)

201408/201408 好的

我在运行PHP 5.2的生产服务器上发现了这种行为,所以我认为这是一个古老的错误,但它发生在PHP 5.3(http://phptester.net/)和我们的测试服务器上的5.5.

如果我在PHP 5.2中使用"本月的第一天",则会出现相同的行为.在PHP 5.5中,"本月的第一天"按预期工作.

是"第一天" - 行为是一个错误吗?如何在PHP 5.2中获得"本月的第一天"而不进行奇怪的转换stringdate

php datetime

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

Javascript彩色动画

我想在原始javascript中将1种颜色的动画(过渡)转换为另一种颜色.

我不想使用任何框架(jquery,mootools)或css3.纯粹的原始javascript.

我真的很难做到这一点,有人可以帮助我吗?:)

javascript animation transition colors

5
推荐指数
2
解决办法
2万
查看次数