小编Maj*_*ter的帖子

视差滚动视图(雅虎天气般喜欢)

这不是一个严格的编程问题,而是更多的"如何实现这个"问题.

我很好奇(并且正在研究可能需要这个的应用程序)如何实现左右视差滚动.要确切了解我的意思,请查看Yahoo Weather应用程序(它是免费的 - 不用担心).

他们是否仅为每个视图使用一个视图控制器或单独的控制器?
实现这个的最简单方法是什么?我在这里找到了这个主题,有点解释了一下,但他们什么时候从他们的服务器获取信息?是在更改视图时还是在应用程序启动时?

任何有关如何实现这种滚动的信息都将非常受欢迎.

graphics ios parallax

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

Cocos2d触摸调度程序导致对象保留

我有cocos2d的问题.我做了一个接受触摸的课程.类的子类CCLayerinit看起来像这样:

- (id)initWithFrame:(CGRect)frameSize
{
    self = [super init];
    if (self)
    {
        frame = frameSize;
        size = frame.size;
        origin = frame.origin;
        [[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

所以一切都很简单.frame,size并且origin是类变量,但这现在无关紧要.所以我注册了我的班级女巫touchDispatcher,让我可以处理.触摸处理完成如下:

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
    return YES;
}

- (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
{
    //Some touch logic which i need.
}
Run Code Online (Sandbox Code Playgroud)

dealloc我发布所有保留的信息并取消注册touchDispatcher.但从dealloc未被称为.如果我不与注册touchDispatcherdealloc正确调用.如果重要的话,这个类作为子类添加到另一个CCLayer子类中,并且在该类中dealloc我释放了这个类.

我错过了什么?

touch dealloc cocos2d-iphone ios

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

Mac OS X nasm程序集无法正常工作

我花了整整一天试图编写一些简单的程序,但到目前为止运气很少.我想要做的是编译和运行用nasm汇编编写的程序.

我已升级到最新的nasm(v2.10.09).所以,让我跳到代码中,因为我对这些事情还不太了解.这是一大堆汇编代码,使用elf格式和链接巫婆gcc 在linux上运行(评论是我对正在发生的事情的理解):

bits 32
extern printf
global main

section .data
    message db "Hello world!", 10, 0

section .text
main:
    pushad                      ;push all registers on stack
    push dword message                  ;push the string on stack
    call printf                 ;call printf
    add esp, 4                  ;clear stack
    popad                       ;pop all registers back
    ret                     ;return to whoever called me
Run Code Online (Sandbox Code Playgroud)

没什么太大的.但是我到底该如何让它在OS X上运行呢?我甚至无法以任何方式编译/链接.如果它编译我不能链接它(关于i386和x86无法链接在一起的东西(我明白但是如何修复它?)).我已经尝试了十几种没有运气的方法.

进一步哪能printfscanf在OS X组件?

这是另一个徒劳的尝试scanfprintf价值回归(这个实际上编译和链接 - 甚至运行!):

[bits 32] ; why the []?

section .data
    input_string …
Run Code Online (Sandbox Code Playgroud)

c macos assembly gcc nasm

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

克隆系统调用OS X没有链接 - 未定义的符号

我想clone在OS X上使用系统调用.这是一个Unix系统调用,所以它不应该是一个问题,对吧?我已经成功地尝试使用fork,vfork以及其他类似的功能.这是我正在尝试的程序:

#include <sched.h>  //Clone resides here
#include <stdlib.h> //standard library
#include <stdio.h>
#include <time.h>
#include <limits.h>
#include <sys/shm.h>
#include <errno.h>
#include <sys/sem.h>
#include <signal.h>
#include <sys/types.h>

int helloWorld();

int main(int argc, char *argv[])
{
    int (*functionPointer)() = &helloWorld; //The first argument of clone accepts a pointer to a function which must return int
    void **childStack = (void**)malloc(1024); //We will give our child 1kB of stack space

    clone(functionPointer, childStack, 0, NULL); //First arugment is …
Run Code Online (Sandbox Code Playgroud)

c gcc fork clone ld

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

组装ac字符串并通过引用返回它(使用malloc和string.h函数)

我想组装某种HTTP标头(它只是一个有趣的项目).但我的问题更多是关于如何在C中这样做.我有这样的功能:

void assembleResponse(char **response, const unsigned short code, const unsigned long length, const char *contentType)
{
    char *status;
    char *server = {"Server: httpdtest\r\n"};
    char *content = malloc(17 + strlen(contentType));
    char *connection = {"Connection: close"};

    printf("AA");

    strcpy(content, "Content-type: ");
    strcat(content, contentType);
    strcat(content, "\r\n");

    printf("BB");

    switch (code)
    {
    case 200:
       //200 Ok
       status = malloc(sizeof(char) * 18);
       //snprintf(status, 17, "HTTP/1.1 200 Ok\r\n");
       strcpy(status, "HTTP/1.1 200 Ok\r\n");
       break;
    }

    printf("CC");

    unsigned int len = 0;
    len += strlen(status);
    len += strlen(server);
    len += …
Run Code Online (Sandbox Code Playgroud)

c string malloc http strcat

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

标签 统计

c ×3

gcc ×2

ios ×2

assembly ×1

clone ×1

cocos2d-iphone ×1

dealloc ×1

fork ×1

graphics ×1

http ×1

ld ×1

macos ×1

malloc ×1

nasm ×1

parallax ×1

strcat ×1

string ×1

touch ×1