Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
và thanh công cụ, dành thời gian để đọc các Hướng dẫn giao diện con người của Apple, có sẵn như là một phần của tiêu chuẩn A GameKit chứng minh làm thế nào để làm như vậy đã được thêm vào đoạn code mẫu đi kèm với chương này. | Recipe Tappable Overlays 411 - void action id sender Add the subview self.view.window addSubview self.overlay Start the activity indicator UIActivityIndicatorView self.overlay viewWithTag 202 startAnimating Call the finish method on delay self performSelector @selector finish withObject nil afterDelay 3.0f Get This Recipe s Code To get the code used for this recipe go to http github.com erica iphone-3.0-cookbook- or if you ve downloaded the disk image containing all of the sample code from the book go to the folder for Chapter 10 and open the project for this recipe. Recipe Tappable Overlays Use custom overlays to present information as well as to establish modal sequences. Recipe 10-9 creates a custom class called TappableOverlay.When tapped this view removes itself from the screen. This behavior makes it particularly suitable for showing information in a way normally reserved for the UIAlertView class. To use this class create a view instance in Interface Builder. Add as many subviews and design elements as needed. Use File Read Class Files to import the TappableOverlay.h header file.Then change the view class from UIView to TappableOverlay using the Identity Inspector Command-4 and save the project. To present the view add it to the window just as Recipe 10-8 did. - void action id sender Add the overlay self.view.window addSubview self.overlay No further programming is needed. The view waits for a user tap and when one is received it removes itself from the window. Figure 10-8 shows a simple example of this kind of overlay it displays Tap to Continue. It s easy to see how you can extend this concept to show any kind of pertinent information creating a custom alternative to the UIAlertView class.As with Recipe 10-8 this example does not use any orientation awareness. 412 Chapter 10 Alerting Users Figure 10-8 This simple overlay dismisses itself on receiving a user touch. Recipe 10-9 Building a Custom Dismissible Alert View That Responds to User Taps interface .