小编Umu*_*mut的帖子

如何在Xcode 5中使用xib文件而不是storyboard?

我是ios开发的新手,我观看的许多教程都遵循xib方法,因为它们是在XCode 5之前录制的.我如何在单视图应用程序中使用xib方法?当我删除故事板并选择其中一个xib作为主界面时,它无法正常工作.谢谢你的提示.

xcode storyboard xib ios

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

为什么rand()总是返回相同的值?

可能重复:使用rand
在C
中生成随机数以生成随机数

我正在尝试生成随机数,但我不断得到数字41.这样一个简单的片段可能会出错?

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int a = rand();
    printf("%d",a);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

感谢帮助.

c random

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

运算符在c ++中重载+和+ =

我对操作员操作概念非常陌生,之前提出的相关问题远远超过我,所以我需要提出一个基本问题.

这是.h文件:

#define ACCOUNT_H

using namespace std;

class Account{
  friend Account &operator+ (Account &acc);
  friend ostream &operator<< (ostream &, Account &);

  public:
    Account(double=100.0,double=0.0,double=0.0);

    Account &returnSum(Account &otherAccount) const;
    Account& operator+=(Account &Acc1);

    void setT(double);
    void setD(double);
    void setE(double);
    double getT(void);
    double getD(void);
    double getE(void);
    void printAccount();

  private:
    double t;
    double d;
    double e;
};

#endif
Run Code Online (Sandbox Code Playgroud)

我需要重载+作为全局函数"使用单个参数"(这对我来说这是一个具有挑战性的部分)和+=作为成员函数(这里我假设我不能采用右侧操作数,因为它是一个成员函数,所以是有问题的部分).这是我的实现+=:

Account &Account ::operator+=(Account &Acc1){
   Account *result = new Account(Acc1.getT()+t,Acc1.getD()+d,Acc1.getE()+e);
   Acc1 = *result;
   return *this;
}
Run Code Online (Sandbox Code Playgroud)

如果你能纠正这个+=并给我写一个+重载实现,我真的很感激.我只需要将t,d,e值添加为Account对象.

c++ operator-overloading

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

使用createprocess函数的困难时期

首先,我已经阅读了网络上与此功能相关的所有内容,但仍然无法正常使用.我在这里使用msdn页面中使用的相同示例:

http://msdn.microsoft.com/en-us/library/ms682512(VS.85).aspx

我的代码:

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

void _tmain( int argc, TCHAR *argv[] )
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    SecureZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    SecureZeroMemory( &pi, sizeof(pi) );

    if( argc != 2 )
    {
        printf("Usage: %s [cmdline]\n", argv[0]);
        return;
    }

    // Start the child process. 
    if( !CreateProcess( NULL,   // No module name (use command line)
        "C:\\Users\\user\\Desktop\\FreeCell.lnk",        // Command line
        NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance …
Run Code Online (Sandbox Code Playgroud)

c winapi

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

如何让多个Key Binding同时工作?

我需要设计一个有两个玩家的游戏.每个都有一个球,应该能够向右或向左移动球,第一个玩家带有'a''d'按钮,第二个玩家有右箭头按钮.然而,目前一名球员需要等待其他球员的动作完成才能移动他们自己的球.我该如何解决这个问题?这是我的代码的相关部分:

    public class AnimationWindow extends JPanel{

      public AnimationWindow()
        {

            super();
            ....
            ....
            cezmiMover();

        } 



public void cezmiMover(){

        this.getInputMap().put(KeyStroke.getKeyStroke('a'), "left1");
        this.getActionMap().put("left1", new AbstractAction() {

            public void actionPerformed(ActionEvent e) {

                board.cezmi1.moveLeft();
            }
        });

        this.getInputMap().put(KeyStroke.getKeyStroke('d'), "right1");
        this.getActionMap().put("right1", new AbstractAction() {

            public void actionPerformed(ActionEvent e) {

                board.cezmi1.moveRight();
            }
        });

        this.getInputMap().put(KeyStroke.getKeyStroke("LEFT"), "left2");
        this.getActionMap().put("left2", new AbstractAction() {

            public void actionPerformed(ActionEvent e) {

                board.cezmi2.moveLeft();
            }
        });

        this.getInputMap().put(KeyStroke.getKeyStroke("RIGHT"), "right2");
        this.getActionMap().put("right2", new AbstractAction() {

            public void actionPerformed(ActionEvent e) {

                board.cezmi2.moveRight();
            }
        }); 
    }
}
Run Code Online (Sandbox Code Playgroud)

java swing key-bindings actionlistener

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

目标c中的数组排序错误

我在下面的NSDictionary中有4个值,分别是1000,640,80和0,它正确地对非零值进行排序,但它总是给出0大于所有其他值,如(降序):0,1000,640,80这里是代码:

    NSMutableDictionary *dict = [[self model] stateFromDocumentNamed:@"state"];
    NSArray *values=[dict allValues];
    NSMutableArray *mutvalues = [(NSArray*)values mutableCopy];
    [mutvalues sortUsingSelector:@selector(compare:)];
    values=[[values reverseObjectEnumerator] allObjects];
    NSLog(@"%@",mutvalues);
Run Code Online (Sandbox Code Playgroud)

objective-c ios

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