小编Jay*_*Jay的帖子

如何在Swift中更改UILabel的字体大小?

label.font.pointSize 是只读的,所以我不知道如何改变它.

uilabel ios swift

230
推荐指数
7
解决办法
23万
查看次数

如何在Swift iOS应用程序中隐藏状态栏?

我想删除屏幕顶部的状态栏.

这不起作用:

func application
(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: NSDictionary?)
-> Bool
{
        application.statusBarHidden = true
        return true
}
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

func application
(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: NSDictionary?)
-> Bool
{
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

    var controller = UIViewController()
    application.statusBarHidden = true
    controller.setNeedsStatusBarAppearanceUpdate()

    var view = UIView(frame: CGRectMake(0, 0, 320, 568))
    view.backgroundColor = UIColor.redColor()
    controller.view = view

    var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
    label.center = CGPointMake(160, 284)
    label.textAlignment = NSTextAlignment.Center
    label.text = "Hello World"
    controller.view.addSubview(label)

    self.window!.rootViewController = controller
    self.window!.makeKeyAndVisible()
    return …
Run Code Online (Sandbox Code Playgroud)

iphone ios ios7 swift

191
推荐指数
13
解决办法
13万
查看次数

如何使用流对Map中的值求和?

我想要一个与流相当的:

public static <T extends Number> T getSum(final Map<String, T> data) {
    T sum = 0;
    for (String key: data.keySet())
        sum += data.get(key);
    return sum;
}
Run Code Online (Sandbox Code Playgroud)

这段代码实际上并没有编译,因为0不能分配给类型T,但你明白了.

java generics java-8 java-stream

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

VIM:退出插入模式:normal命令

当我使用:normal命令(:normal i)进入插入模式时,如何退出插入模式?

如果我按<Esc>,或<cc>,或<c - [>,VIM退出命令模式,我无法运行my:normal命令.

我输入imap <c-e> <Esc>了我的.vimrc但是当我在命令模式下输入<ce>时,没有插入任何东西.我无法弄清楚如何在命令模式下输入"控制e".

例如,<co>工作,:normal Ihello<c-o>Aworld但有时我想在正常模式下执行多个命令.

我知道我可以使用宏,但我想知道如何使用:正常.

vim macvim

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

如何使用iOS 5 Twitter Framework发送直接消息?

我正在尝试使用代码,并将这些指令用于执行直接消息.发布正常的推文工作得非常好,但是当我尝试发送直接消息时,我得到了406.

这是完整的代码:

ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

// Request access from the user to access their Twitter account
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
    // Did user allow us access?
    if (granted == YES)
    {
        // Populate array with all available Twitter accounts
        NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];

        // Sanity check
        if ([arrayOfAccounts count] > 0) 
        {
            // Keep it simple, use the first account available
            ACAccount *acct = …
Run Code Online (Sandbox Code Playgroud)

iphone twitter ios5

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

如何 tap() 迭代器?

Rust 中的tap()等价物是什么?

它对迭代器中的每个项目调用一个函数map(),但不是传递函数返回的值,而是tap()返回原始项目。

例如,我想以println!()某种方式在流中调用:

foo.into_iter()
  .filter(|x| x == target)
  .tap(|x| println!("{:?}", x)) // <-- what goes here?
  .map(|c| c.result)
Run Code Online (Sandbox Code Playgroud)

更正:

tap()在整个迭代器上调用一次闭包
inspect()在迭代器中的每个项目上调用闭包

functional-programming rust

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

如何检测最大值 递归深度超过了Python中的异常?

try:
    recursive_function()
except RuntimeError e:
    # is this a max. recursion depth exceeded exception?
Run Code Online (Sandbox Code Playgroud)

如何判断何时达到最大递归深度?

python

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

如何在cocos2d中获取屏幕中心?

如何在Cocos2d-iPhone中获得位于屏幕中心的点的世界空间坐标?

cocos2d-iphone

6
推荐指数
1
解决办法
8322
查看次数

Kafka 是否有可见性超时?

Kafka 是否有类似于 SQS 可见性超时的东西?

物业叫什么?我似乎在文档中找不到这样的东西。

apache-kafka

6
推荐指数
1
解决办法
916
查看次数

iOS <5无法加载twitter框架

我正在使用这里的说明来检测iOS 5设备上的Twitter框架.问题是旧设备没有Twitter库,所以我在iOS 4上收到以下错误:

dyld: Library not loaded: /System/Library/Frameworks/Twitter.framework/Twitter
Run Code Online (Sandbox Code Playgroud)

如何创建一个可以在iOS 5上使用Twitter框架并在iOS 4及更低版本上使用不同API的应用程序?

iphone twitter objective-c ios

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

如何从Python中的请求处理程序中关闭HTTPServer?

收到StopIteration异常后,如何关闭此服务器?sys.exit()不起作用.

#!/usr/bin/env python

from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer

PORT_NUMBER = 2000

from itertools import islice
filename = 'data/all.txt'
file = open(filename, 'r')
lines_gen = islice(file, None)

class MyHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        global lines_gen

        self.send_response(200)
        self.send_header('Content-type','text/plain')
        self.end_headers()

        try:
            for i in range(10):
                next_line = lines_gen.next()
                self.wfile.write(next_line)
        except StopIteration:
            # return response and shutdown the server
            # ?????

        return

try:
    server = HTTPServer(('', PORT_NUMBER), MyHandler)
    print('Started httpserver on port ' , PORT_NUMBER)
    server.serve_forever()

except KeyboardInterrupt:
    print('^C received, shutting down the web server')
    server.socket.close()
Run Code Online (Sandbox Code Playgroud)

python basehttpserver

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

Javascript 6中的字典和地图有什么区别?

Map如何与字典/对象不同?

换句话说,let x = {}和之间有什么区别let x = new Map()

javascript ecmascript-6

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