Class: UIActionSheet
Overview
Use the UIActionSheet class to present the user with a set of alternatives for how to proceed with a given task. You can also use action sheets to prompt the user to confirm a potentially dangerous action. The action sheet contains an optional title and one or more buttons, each of which corresponds to an action to take.
Instance Attribute Summary (collapse)
-
- actionSheetStyle
The receiver’s presentation style.
-
- cancelButtonIndex
The index number of the cancel button.
-
- delegate
The receiver’s delegate or nil if it doesn’t have a delegate.
-
- destructiveButtonIndex
The index number of the destructive button.
-
- firstOtherButtonIndex
readonly
The index of the first custom button.
-
- numberOfButtons
readonly
The number of buttons on the action sheet.
-
- title
The string that appears in the receiver’s title bar.
-
- visible
readonly
A Boolean value that indicates whether the receiver is displayed.
Attributes inherited from UIView
#alpha, #autoresizesSubviews, #autoresizingMask, #backgroundColor, #bounds, #center, #clearsContextBeforeDrawing, #clipsToBounds, #contentMode, #contentScaleFactor, #exclusiveTouch, #frame, #gestureRecognizers, #hidden, #layer, #multipleTouchEnabled, #opaque, #restorationIdentifier, #subviews, #superview, #tag, #transform, #userInteractionEnabled, #window
Attributes inherited from UIResponder
#inputAccessoryView, #inputView, #undoManager
Instance Method Summary (collapse)
-
- addButtonWithTitle:
Adds a custom button to the action sheet.
-
- buttonTitleAtIndex:
Returns the title of the button at the specified index.
-
- dismissWithClickedButtonIndex:animated:
Dismisses the action sheet immediately using an optional animation.
-
- initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:
Initializes the action sheet using the specified starting parameters.
-
- showFromBarButtonItem:animated:
Displays an action sheet that originates from the specified bar button item.
-
- showFromRect:inView:animated:
Displays an action sheet that originates from the specified view.
-
- showFromTabBar:
Displays an action sheet that originates from the specified tab bar.
-
- showFromToolbar:
Displays an action sheet that originates from the specified toolbar.
-
- showInView:
Displays an action sheet that originates from the specified view.
Methods inherited from UIView
#addConstraint:, #addConstraints:, #addGestureRecognizer:, #addSubview:, #alignmentRectForFrame:, #alignmentRectInsets, animateWithDuration:animations:, animateWithDuration:animations:completion:, animateWithDuration:delay:options:animations:completion:, areAnimationsEnabled, beginAnimations:context:, #bringSubviewToFront:, commitAnimations, #constraints, #constraintsAffectingLayoutForAxis:, #contentCompressionResistancePriorityForAxis:, #contentHuggingPriorityForAxis:, #convertPoint:fromView:, #convertPoint:toView:, #convertRect:fromView:, #convertRect:toView:, #decodeRestorableStateWithCoder:, #didAddSubview:, #didMoveToSuperview, #didMoveToWindow, #drawRect:, #drawRect:forViewPrintFormatter:, #encodeRestorableStateWithCoder:, #endEditing:, #exchangeSubviewAtIndex:withSubviewAtIndex:, #exerciseAmbiguityInLayout, #frameForAlignmentRect:, #gestureRecognizerShouldBegin:, #hasAmbiguousLayout, #hitTest:withEvent:, #initWithFrame:, #insertSubview:aboveSubview:, #insertSubview:atIndex:, #insertSubview:belowSubview:, #intrinsicContentSize, #invalidateIntrinsicContentSize, #isDescendantOfView:, layerClass, #layoutIfNeeded, #layoutSubviews, #needsUpdateConstraints, #pointInside:withEvent:, #removeConstraint:, #removeConstraints:, #removeFromSuperview, #removeGestureRecognizer:, requiresConstraintBasedLayout, #sendSubviewToBack:, setAnimationBeginsFromCurrentState:, setAnimationCurve:, setAnimationDelay:, setAnimationDelegate:, setAnimationDidStopSelector:, setAnimationDuration:, setAnimationRepeatAutoreverses:, setAnimationRepeatCount:, setAnimationStartDate:, setAnimationTransition:forView:cache:, setAnimationWillStartSelector:, setAnimationsEnabled:, #setContentCompressionResistancePriority:forAxis:, #setContentHuggingPriority:forAxis:, #setNeedsDisplay, #setNeedsDisplayInRect:, #setNeedsLayout, #setNeedsUpdateConstraints, #setTranslatesAutoresizingMaskIntoConstraints:, #sizeThatFits:, #sizeToFit, #systemLayoutSizeFittingSize:, transitionFromView:toView:duration:options:completion:, transitionWithView:duration:options:animations:completion:, #translatesAutoresizingMaskIntoConstraints, #updateConstraints, #updateConstraintsIfNeeded, #viewForBaselineLayout, #viewPrintFormatter, #viewWithTag:, #willMoveToSuperview:, #willMoveToWindow:, #willRemoveSubview:
Methods inherited from UIResponder
#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (UIActionSheetStyle) actionSheetStyle
The receiver’s presentation style. This property determines how the action sheet looks when it is presented. For a list of possible values, see the UIActionSheetStyle constants.
- (Integer) cancelButtonIndex
The index number of the cancel button. Button indices start at 0. The default value of this property is normally -1, which indicates that no cancel button has been set. However, a cancel button may be created and set automatically by the initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles: method. If you use that method to create a cancel button, you should not change the value of this property.When presenting an action sheet on an iPad, there are times when you should not include a cancel button. For more information on when you should include a cancel button, see the class overview or iOS Human Interface Guidelines.
- (Object) delegate
The receiver’s delegate or nil if it doesn’t have a delegate. For a list of methods your delegate object can implement, see UIActionSheetDelegate Protocol Reference.
- (Integer) destructiveButtonIndex
The index number of the destructive button. Button indices start at 0. The default value of this property is normally -1, which indicates that no destructive button has been set. However, a destructive button may be created and set automatically by the initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles: method. If you use that method to create a destructive button, you should not change the value of this property.
- (Integer) firstOtherButtonIndex (readonly)
The index of the first custom button. (read-only) Button indices start at 0. The default value of this property is -1, which indicates that there are no other custom buttons.
- (Integer) numberOfButtons (readonly)
The number of buttons on the action sheet. (read-only)
- (String) title
The string that appears in the receiver’s title bar.
- (Boolean) visible (readonly)
A Boolean value that indicates whether the receiver is displayed. (read-only) If YES, the receiver is displayed; otherwise, NO.
Instance Method Details
- (Integer) addButtonWithTitle(title)
Adds a custom button to the action sheet.
- (String) buttonTitleAtIndex(buttonIndex)
Returns the title of the button at the specified index.
- (Object) dismissWithClickedButtonIndex(buttonIndex, animated:animated)
Dismisses the action sheet immediately using an optional animation. You can use this method to dismiss the action sheet programmatically as needed. The action sheet also calls this method itself in response to the user tapping one of the buttons in the action sheet. In iOS 4.0, you may want to call this method whenever your application moves to the background. An action sheet is not dismissed automatically when an application moves to the background. This behavior differs from previous versions of the operating system, where they were canceled automatically when the application was terminated. Dismissing the action sheet gives your application a chance to save changes or abort the operation and perform any necessary cleanup in case your application is terminated later.
- (Object) initWithTitle(title, delegate:delegate, cancelButtonTitle:cancelButtonTitle, destructiveButtonTitle:destructiveButtonTitle, otherButtonTitles:otherButtonTitles, ...)
Initializes the action sheet using the specified starting parameters. The action sheet automatically sets the appearance of the destructive and cancel buttons. If the action sheet contains only one button, it does not apply the custom colors associated with the destructive and cancel buttons.
- (Object) showFromBarButtonItem(item, animated:animated)
Displays an action sheet that originates from the specified bar button item. On iPad, this method presents the action sheet in a popover and adds the toolbar that owns the button to the popover’s list of passthrough views. Thus, taps in the toolbar result in the action methods of the corresponding toolbar items being called. If you want the popover to be dismissed when a different toolbar item is tapped, you must implement that behavior in your action handler methods.
- (Object) showFromRect(rect, inView:view, animated:animated)
Displays an action sheet that originates from the specified view. On iPad, this method displays the action sheet in a popover whose arrow points to the specified rectangle of the view. The popover does not overlap the specified rectangle.
- (Object) showFromTabBar(view)
Displays an action sheet that originates from the specified tab bar. The appearance of the action sheet is animated.On iPad, this method centers the action sheet in the middle of the screen. Generally, if you want to present an action sheet relative to a tab bar in an iPad application, you should use the showFromRect:inView:animated: method instead.
- (Object) showFromToolbar(view)
Displays an action sheet that originates from the specified toolbar. The appearance of the action sheet is animated.On iPad, this method centers the action sheet in the middle of the screen. Generally, if you want to present an action sheet relative to a toolbar in an iPad application, you should use the showFromBarButtonItem:animated: method instead.
- (Object) showInView(view)
Displays an action sheet that originates from the specified view. The appearance of the action sheet is animated.On iPad, this method centers the action sheet in the middle of the screen. Generally, if you want to present an action sheet in an iPad application, you should use the showFromRect:inView:animated: method to display the action sheet instead.