TAILIEUCHUNG - Praise for The iPhone Developer’s Cookbook 2nd phần 7

nơi mà người dùng lựa chọn giữa trực tuyến và gần đó, nó cho thấy giao diện trong hình không có để sử dụng một hộp thoại chọn bạn bè để thành lập GameKit iPhone SDK cho phép bạn tạo ra các giao diện tùy chỉnh của riêng bạn để làm việc với các mẫu cơ bản connections. | Recipe Creating Basic GameKit Services 499 where a user selects between Online and Nearby presented it shows the interface in Figure do not have to use a peer picker to establish GameKit sessions. The iPhone SDK now lets you create your own custom interfaces to work with the underlying GameKit connections. A sample that demonstrates how to do so has been added to the sample code that accompanies this chapter. Create and present a new peer picker GKPeerPickerController picker GKPeerPickerController alloc init self GKPeerPickerConnectionTypeNearby picker show When your mask includes the online type as well GKPeerPickerConnectionTypeOnline the picker first asks the user which kind of connection to use before moving on to either the nearby connection interface of Figure 12-2 or to a custom online interface that you must build yourself. Figure 12-2 This is the first screen presented to the user for peer-to-peer Bluetooth connections. Pressing Cancel Users may cancel out of the peer picker they do so the delegate receives a peerPickerControllerDidCancel callback. If you display a connect button in your application make sure to restore it at this point so the user can try again. 500 Chapter 12 Making Connections with GameKit and Bonjour Creating the Session Object As the picker delegate you must supply a session object on request. Sessions which provide an abstract class that creates and manages a data socket between devices belong to the GKSession class and must be initialized with a session is the unique string used to create the Bonjour service and link together two iPhone devices peers both advertising the same service. By setting the display name to nil the session uses the built-in device name. - GKSession peerPickerController GKPeerPickerController picker sessionForConnectionType GKPeerPickerConnectionType type Create a new session if one does not already exist if

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.