//设置.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);
}
当我运行它时。我的视图将设置 -> 游戏板。tcp 服务器将创建并运行循环以接收传入的数据,然后 .y 视图将在游戏板上停止并等待来自设置的数据(缓冲区)调用 activateButton。在调用 activateButton 之后,它也应该运行这些行
btnMyButton.enabled = YES;
image2.center= CGPointMake(xPos,yPos);
但是我的按钮仍然禁用并且我的 image2 仍然没有更新位置我还使用 UIAlertView 进行测试,它在调用时仍然会弹出。
谁能告诉我发生了什么事?以及如何解决它
非常感谢。