UIButton's UIActionSheet operation table Parameter Parsing

Source: Internet
Author: User

Add a UIButton button to the ViewController. xib file, and then implement a prompt window:
The related implementation code is as follows:
[Plain]
1.-(IBAction) doSomething :( id) sender
2 .{
3. UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: @ "Are you sure? "Delegate: self cancelButtonTitle: @" No Way "destructiveButtonTitle: @" yes, I'm Sure "otherButtonTitles: nil];
4. [actionSheet showInView: self. view];
5. [actionSheet release];
6 .}
 
What is the role of the doSomething method? We first allocate and initialize a UIActionSheet object, which represents an operation table:
The initialization method accepts five parameters. The parameter meanings are as follows:
The first parameter is initWithTitle, which is the title of the operation table.
The second parameter: delegate: The delegate to operate the table. A notification will be received when the button on the table is pressed. More specifically, the delegate ActionSheet: didDismissWithButtonIndex: actionSheet: didDismisswithButtonIndex: the method is called. By passing self as the delegate parameter to this method, we can ensure that the actionSheet: didDismisswithButtonIndex: Method of this program will be called.
CancelButtonTitle: the title of the cancel button. You can click this button to indicate that you do not want to continue the operation. All operation tables should have a Cancel button, but you can specify a proper title for them as needed. If not selected, you do not need to use the operation table. If you only want to notify the user, but do not allow the user to make a choice, it is more appropriate to use the notification.
DestructiveButtonTitle: determines the button title, which is the opposite of the title.
OtherButtonTitle: specifies the number of other buttons that you want to implement on the form. This parameter can use various values. This is a feature in the OC language. If you want two buttons on the operation table, you can write the following code:
[Plain]
1. otherButtonTitle: @ "Foo", @ "Bar", nil;
 
[Plain]
1. In this way, the operation table provides four buttons for users to choose from. You can pass any number of variables in the otherButtonTitles parameter, As long as nil is passed as the last variable. However, according to the size of the available screen space, the number of buttons is actually limited.
 
[Plain]
1. After creating an operation table, the operation table always has a parent view, that is, the view currently visible to users. In this example, we want to use the view designed in Interface Builder as the parent view, so we use self. view. View is an attribute of the parent class UIViewController, pointing to the view corresponding to the Controller of this class.
 



From Anno's column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.