How to make connection over WiFi when working with Gamekit?

江枫思渺然 提交于 2020-02-01 04:26:19

问题


I want to make connection between two devices over WiFi using GameKit. Apple's documentation says

If an Internet connection is chosen, your application must dismiss the peer picker dialog and present its own user interface to complete the connection.

This is what i do

- (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type
{
if (type == GKPeerPickerConnectionTypeOnline) 
{
    picker.delegate = nil;
    [picker dismiss];
    [picker autorelease];

    [alert setTitle:@"\n\n\n"];
    [alert setMessage:@"Looking for other iPads, iPhones or iPod touches..."];
    [alert addButtonWithTitle:@"Cancel"];

    UIActivityIndicatorView *progress   = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
    progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
    [alert addSubview:progress];
    [progress startAnimating];
    [alert show];
}
}

Ok, i have presented my own interface. And what next? How do i connect? How to start looking for peers?


回答1:


This tutorial builds peer to peer card game using Gamekit and either Bluetooth or wifi. (link updated)



来源:https://stackoverflow.com/questions/10862670/how-to-make-connection-over-wifi-when-working-with-gamekit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!