小编Myk*_*ola的帖子

如何向NSDictionary添加布尔值?

好吧,对于整数我会用NSNumber.但是,我想,YES和NO不是对象.Afaik我只能添加对象NSDictionary,对吧?

我找不到布尔值的任何包装类.有没有?

iphone cocoa-touch objective-c uikit

112
推荐指数
3
解决办法
7万
查看次数

如何将int []连接到.NET中的字符分隔字符串?

我有一个整数数组:

int[] number = new int[] { 2,3,6,7 };
Run Code Online (Sandbox Code Playgroud)

将这些转换为单个字符串的最简单方法是什么,其中数字由字符分隔(如:)"2,3,6,7"

我在C#和.NET 3.5中.

.net c# .net-3.5

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

如果父文件夹不存在,如何写文件?

我需要将文件写入以下路径:

 fs.writeFile('/folder1/folder2/file.txt', 'content', function () {

 });
Run Code Online (Sandbox Code Playgroud)

'/folder1/folder2'路径可能不存在.所以我收到以下错误:

 message=ENOENT, open /folder1/folder2/file.txt
Run Code Online (Sandbox Code Playgroud)

如何将内容写入该路径?

file-io file node.js

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

iOS Segue - 从左到右 -

我已经阅读了有关segues的其他帖子但没有解决我的问题.

简单地说,我ViewController的订单就像一本书.我希望向后过渡(例如:从第9页到第8页)始终从左到右呈现(滑过).我希望从右到左呈现前向过渡(从第9页到第10页).

是的,如果您逐页翻页,我的导航控制器后退按钮(左上角)会显示如下内容.但是,如果从索引中跳转,则导航控制器上的后退功能会将您带回索引.

我的目标是,如果用户从索引跳到第9页(例如),然后向右滑动,它将向右滑动页面并显示第8页.一旦在第8页,如果他们向左轻弹页面将向左轻弹,他们将再次出现在第9页.

ViewController默认情况下,我所有人都是从右到左滑动.

示例:将其想象成一本书,如果我使用索引跳到第4章,然后向右滑动并从堆栈中弹出一个视图,我将回到索引.但是,如果您使用第394章第4章并向右滑动,则不希望返回索引!您想要转到第393页第3章的最后一页!因此导航堆栈对我没有帮助.

结束例子

详细信息:1.我在按钮上使用新的Xcode"Show"在ViewControllers之间切换.

  1. 我正在使用导航控制器,左上角的"后退"按钮功能.这使用导航堆栈并且工作正常.

  2. 但是我在底部有自己的自定义导航栏(后退按钮,主页按钮,索引按钮,前进按钮)和手势.这些是我想要的书籍功能.

  3. 快速编码.

  4. 使用Xcode 6.3

我读过有动画代码.我已经阅读了可以使用的深度程序转换.只是选择我想要从左边呈现的segue并轻松地反转动画,这似乎很疯狂.

谢谢!

尝试记录:

I tried DCDC's code:
    UIView.transitionWithView(self.window!, duration: 0.5, options:.TransitionFlipFromLeft, animations: { () -> Void in
            self.window!.rootViewController = mainVC
            }, completion:nil)
Run Code Online (Sandbox Code Playgroud)

当我将DCDC的代码插入到IBAction我的后滑动中时,会返回此错误

当我将DCDC的代码插入IBAction进行反刷时,会返回此错误

uiviewanimation ios segue swift xcode6

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

C#:改变列表框的行颜色?

我想改变一些行的背景颜色ListBox.我有两个列表,其中一个有名称,并显示在一个ListBox.第二个列表与第一个列表具有相似的值List.单击按钮时,我想搜索ListBox第二个List,然后更改ListBox出现在那些值中的颜色List.我的搜索结果ListBox如下:

for (int i = 0; i < listBox1.Items.Count; i++)
{
    for (int j = 0; j < students.Count; j++)
    {
        if (listBox1.Items[i].ToString().Contains(students[j].ToString()))
        {
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但我不知道使用哪种方法来改变ListBox行的外观.有谁能够帮我?

**编辑:**

我写了我的代码如下:

private void ListBox1_DrawItem(object sender, DrawItemEventArgs e)
{
    e.DrawBackground();
    Graphics g = e.Graphics;
    Brush myBrush = Brushes.Black;
    Brush myBrush2 = Brushes.Red;
    g.FillRectangle(new SolidBrush(Color.Silver), e.Bounds);
    e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, myBrush, e.Bounds, StringFormat.GenericDefault);
    for (int i = …
Run Code Online (Sandbox Code Playgroud)

c# listbox

34
推荐指数
3
解决办法
11万
查看次数

如何在laravel 4上显示错误?

我正在尝试在Laravel 4 beta上创建一个应用程序,但我无法调试它,因为它没有显示任何错误,display_errors是on,error_reportingis E_ALLdebug => true(config/app.php).当我尝试public/index.php对它执行错误时显示解析错误,但是当我在路由器上执行此操作时,它只显示一个空白页面(白屏死机).我怎样才能解决这个问题?

谢谢

debugging error-reporting laravel laravel-4

27
推荐指数
3
解决办法
10万
查看次数

使用IIS Express但不是Visual Studio Development Server,HttpContext.Current.User.Identity.Name为空

HttpContext.Current.User.Identity.Name 当Visual Studio设置为"使用本地IIS Web服务器"时为空/空白,但在Visual Studio设置为"使用Visual Studio开发服务器"时正常工作.

希望您可以通过执行以下操作在Visual Studio 2010或2012中复制此问题(我已尝试过两者):

创建一个选中".NET Framework 4"的新"ASP.NET空Web应用程序",并将其命名为"WindowsAuthTest2".用.替换Web.config的内容

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Windows">
    </authentication>
  </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

接下来,在名为"Default.aspx"的项目中添加一个新的"Web窗体".用Default替换Default.aspx中的代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WindowsAuthTest2.Default" %>

<html>
    <head>
        <title></title>
    </head>
    <body>
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

并用Default替换Default.aspx.cs中的代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WindowsAuthTest2
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = "[" + HttpContext.Current.User.Identity.Name + "]"; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net identity visual-studio

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

如何在onSaveInstanceState中使用变量

我刚刚开始在android学习编程,我在使用变量时遇到了问题onSaveInstanceState.这是我的代码:

int resultCode;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    if (savedInstanceState != null) {
        super.onRestoreInstanceState(savedInstanceState);

        int resultCode = savedInstanceState.getInt("resultCode");
    } 

    Button btnOpenWithResult = (Button) findViewById(R.id.btnOpenWithResult);
    btnOpenWithResult.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent myIntent = new Intent(flashlight.this, ThirdActivity.class);
            startActivityForResult(myIntent, 1);
        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (resultCode) {
    case 1:   
         /** option 1  */            
        break;
    case 2:
         /** option 2 */
        break;
} …
Run Code Online (Sandbox Code Playgroud)

android

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

如何检查每个组中是否存在值(分组后)

假设我有一个订阅表:

uid  | subscription_type 
------------------------  
Alex | type1
Alex | type2
Alex | type3
Alex | type4
Ben  | type2
Ben  | type3
Ben  | type4
Run Code Online (Sandbox Code Playgroud)

并且只想选择具有2个以上订阅但从未订阅类型1的用户

预期的结果是仅选择"Ben".

我很容易找到超过2个订阅的用户使用:

SELECT uid
FROM subscribes
GROUP BY uid
HAVING COUNT(*) > 2
Run Code Online (Sandbox Code Playgroud)

但是如何检查组中是否存在某些值?

谢谢您的帮助!

sql postgresql

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

Node.js/Express/Mocha/Supertest Rest API - 空请求正文

我到处寻找可以找到解决方案.我发现的唯一一件事是没有回复的帖子.如果我忽略了某些事情,我会道歉.

问题是,当我尝试获取API中的POST值时/createQuestion,正文是空的/未定义的.我Cannot read proprety 'question' of undefined从API 那里得到这样的错误.

Express API:

app.post("/createQuestion", function(req, res) {
    var questionType = req.body.question.type;
    var questionText = req.body.question.text;
    var questionDuringClass = req.body.question.duringClass;

    // Do a bunch of stuff

    res.send(response);
});
Run Code Online (Sandbox Code Playgroud)

考试:

    var should = require('should'); 
    var assert = require('assert');
    var request = require('supertest');  
    var winston = require('winston');

    request = request('http://localhost:8080');

        describe('Questions', function() { // Test suite
            before(function(done) {
                done();
            });

        it('Should create a freeResponse question', function(done) { // Test case …
Run Code Online (Sandbox Code Playgroud)

rest mocha.js node.js express supertest

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