【发布时间】:2013-09-19 08:41:53
【问题描述】:
我希望我发布这个问题没有违反保密协议。
我正在使用新的多点连接通过蓝牙将一些文件发送到附近的设备。我已经设法发送邀请,但我似乎不知道如何显示 UIAlertView 用户可以接受或拒绝邀请的地方。现在当用户发送时,文件会自动保存,并且没有接受/拒绝警报。
代码是:
- (void) advertiser:(MCNearbyServiceAdvertiser *)advertiser
didReceiveInvitationFromPeer:(MCPeerID *)peerID
withContext:(NSData *)context
invitationHandler:(void(^)(BOOL accept,
MCSession *session))invitationHandler{
... save the data context
但有警报:
- (void) advertiser:(MCNearbyServiceAdvertiser *)advertiser
didReceiveInvitationFromPeer:(MCPeerID *)peerID
withContext:(NSData *)context
invitationHandler:(void(^)(BOOL accept,
MCSession *session))invitationHandler{
DevicePeer = [MCPeerID alloc];
DevicePeer = peerID;
ArrayInvitationHandler = [NSArray arrayWithObject:[invitationHandler copy]];
// ask the user
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@""
message:@""
delegate:self
cancelButtonTitle:@"NO"
otherButtonTitles:@"YES", nil];
[alertView show];
alertView.tag = 2;
}
和警报查看方法:
- (void) alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
// retrieve the invitationHandler
// get user decision
BOOL accept = (buttonIndex != alertView.cancelButtonIndex) ? YES : NO;
// respond
MCSession *session = [ArrayInvitationHandler objectAtIndex:0];
void (^invitationHandler)(BOOL, MCSession *) = [ArrayInvitationHandler objectAtIndex:0];
invitationHandler(accept, session);
}
当用户按下“是”时,应用程序崩溃并出现错误:
[__NSMallocBlock__ nearbyConnectionDataForPeer:withCompletionHandler:]: unrecognized selector sent to instance 0x14d4e3b0'
我查了IOS开发者库,除了
没有这个方法- (void)nearbyConnectionDataForPeer:(id)arg1 withCompletionHandler:(id)arg2{
}
这不起作用。 IOS 开发者论坛上没有信息。有什么想法吗?
【问题讨论】:
-
请人回答!!这对我很重要
标签: ios multipeer-connectivity