我有一个名为MatchmakingServer的类有如下方法:
- (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state
{
switch (state)
{
case GKPeerStateAvailable:
break;
case GKPeerStateUnavailable:
break;
// A new client has connected to the server.
case GKPeerStateConnected:
if (_serverState == ServerStateAcceptingConnections)
{
if (![_connectedClients containsObject:peerID])
{
NSString *peerID2 =[self displayNameForPeerID:peerID];
self.PeerId=peerID;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops:("
message:[NSString stringWithFormat:@"%@:%@ %@",@"device",peerID2,@"want to join your session"]
delegate:self
cancelButtonTitle:@"NO"
otherButtonTitles:nil];
[_connectedClients addObject:peerID];
NSLog(@"the orginal peerID %@",peerID);
[self.delegate matchmakingServer:self clientDidConnect:peerID];
}
}
也
@interface MatchmakingServer : NSObject <GKSessionDelegate,UIAlertViewDelegate>
任何想法为什么alertView不会调用clickedButtonAtIndex
答案 0 :(得分:0)
您没有在屏幕上显示警报视图,您只是在初始化它。插入
[alert show];
在初始化代码之后你应该没问题。
答案 1 :(得分:0)
您需要在[alert show];
文件中调用UIAlertViewDelegate
方法并采用UIViewController.h
。