// setup.m
void receiveData(CFSocketRef s, CFSocketCallBackType type,
CFDataRef address, const void *data, void *info)
{
gameboard *board = [[gameboard alloc] initWithNibName:nil bundle:nil];
NSString *buffer = [[NSString alloc] initWithData:(NSData *)data
encoding:NSUTF8StringEncoding];
NSLog(@"Buffer is %@", buffer);
[board activateButton:buffer];
// gameboard.m
-(void) activateButton:(NSString *)trigger;{
[self viewDidLoad];
NSLog(@"Received from setup: %@", trigger);
upDatePos = [trigger intValue];
NSLog(@"upDatePos is %d",upDatePos);
btnMyButton.enabled = YES;
[self drawPosition:upDatePos];
NSLog(@"End of activateButton");
}
-(void) p2drawPosition:(int)number;{
NSLog(@"Number in p2draw Position is %d",number);
xPos = [[P2XArraypos objectAtIndex:number]intValue];
yPos = [[P2YArraypos objectAtIndex:number]intValue];
NSLog(@"xPos is %f",xPos);
NSLog(@"yPos is %f",yPos);
image2.center= CGPointMake(xPos,yPos);
}
当我运行它时。我的视图将被设置 - > gameboard.tcp服务器将创建和runloop接收传入的数据然后.y视图将停止在游戏板上并等待设置中的数据(缓冲区)调用activateButton。在activateButton调用之后,它也应该运行这些行
btnMyButton.enabled = YES;
image2.center= CGPointMake(xPos,yPos);
但我的按钮仍然禁用,而我的image2仍未更新位置 我也用UIAlertView进行测试,它在调用时仍会弹出。
有谁能告诉我发生了什么事?以及如何解决它
非常感谢。