#[repr(C)]pub struct BEScrollView { /* private fields */ }
BEScrollView
only.Expand description
Implementations§
Source§impl BEScrollView
impl BEScrollView
pub unsafe fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn BEScrollViewDelegate>>>
Sourcepub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn BEScrollViewDelegate>>,
)
pub unsafe fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn BEScrollViewDelegate>>, )
This is a weak property.
Setter for delegate
.
Source§impl BEScrollView
Methods declared on superclass UIView
.
impl BEScrollView
Methods declared on superclass UIView
.
Methods from Deref<Target = UIScrollView>§
pub unsafe fn adjustedContentInsetDidChange(&self)
pub unsafe fn contentInsetAdjustmentBehavior( &self, ) -> UIScrollViewContentInsetAdjustmentBehavior
Sourcepub unsafe fn setContentInsetAdjustmentBehavior(
&self,
content_inset_adjustment_behavior: UIScrollViewContentInsetAdjustmentBehavior,
)
pub unsafe fn setContentInsetAdjustmentBehavior( &self, content_inset_adjustment_behavior: UIScrollViewContentInsetAdjustmentBehavior, )
Setter for contentInsetAdjustmentBehavior
.
pub unsafe fn automaticallyAdjustsScrollIndicatorInsets(&self) -> bool
Sourcepub unsafe fn setAutomaticallyAdjustsScrollIndicatorInsets(
&self,
automatically_adjusts_scroll_indicator_insets: bool,
)
pub unsafe fn setAutomaticallyAdjustsScrollIndicatorInsets( &self, automatically_adjusts_scroll_indicator_insets: bool, )
Setter for automaticallyAdjustsScrollIndicatorInsets
.
pub unsafe fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn UIScrollViewDelegate>>>
Sourcepub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn UIScrollViewDelegate>>,
)
pub unsafe fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn UIScrollViewDelegate>>, )
This is a weak property.
Setter for delegate
.
pub unsafe fn isDirectionalLockEnabled(&self) -> bool
Sourcepub unsafe fn setDirectionalLockEnabled(&self, directional_lock_enabled: bool)
pub unsafe fn setDirectionalLockEnabled(&self, directional_lock_enabled: bool)
Setter for isDirectionalLockEnabled
.
pub unsafe fn bounces(&self) -> bool
Sourcepub unsafe fn setBounces(&self, bounces: bool)
pub unsafe fn setBounces(&self, bounces: bool)
Setter for bounces
.
pub unsafe fn bouncesHorizontally(&self) -> bool
Sourcepub unsafe fn setBouncesHorizontally(&self, bounces_horizontally: bool)
pub unsafe fn setBouncesHorizontally(&self, bounces_horizontally: bool)
Setter for bouncesHorizontally
.
pub unsafe fn bouncesVertically(&self) -> bool
Sourcepub unsafe fn setBouncesVertically(&self, bounces_vertically: bool)
pub unsafe fn setBouncesVertically(&self, bounces_vertically: bool)
Setter for bouncesVertically
.
pub unsafe fn alwaysBounceVertical(&self) -> bool
Sourcepub unsafe fn setAlwaysBounceVertical(&self, always_bounce_vertical: bool)
pub unsafe fn setAlwaysBounceVertical(&self, always_bounce_vertical: bool)
Setter for alwaysBounceVertical
.
pub unsafe fn alwaysBounceHorizontal(&self) -> bool
Sourcepub unsafe fn setAlwaysBounceHorizontal(&self, always_bounce_horizontal: bool)
pub unsafe fn setAlwaysBounceHorizontal(&self, always_bounce_horizontal: bool)
Setter for alwaysBounceHorizontal
.
pub unsafe fn isPagingEnabled(&self) -> bool
Sourcepub unsafe fn setPagingEnabled(&self, paging_enabled: bool)
pub unsafe fn setPagingEnabled(&self, paging_enabled: bool)
Setter for isPagingEnabled
.
pub unsafe fn isScrollEnabled(&self) -> bool
Sourcepub unsafe fn setScrollEnabled(&self, scroll_enabled: bool)
pub unsafe fn setScrollEnabled(&self, scroll_enabled: bool)
Setter for isScrollEnabled
.
pub unsafe fn transfersHorizontalScrollingToParent(&self) -> bool
Sourcepub unsafe fn setTransfersHorizontalScrollingToParent(
&self,
transfers_horizontal_scrolling_to_parent: bool,
)
pub unsafe fn setTransfersHorizontalScrollingToParent( &self, transfers_horizontal_scrolling_to_parent: bool, )
Setter for transfersHorizontalScrollingToParent
.
pub unsafe fn transfersVerticalScrollingToParent(&self) -> bool
Sourcepub unsafe fn setTransfersVerticalScrollingToParent(
&self,
transfers_vertical_scrolling_to_parent: bool,
)
pub unsafe fn setTransfersVerticalScrollingToParent( &self, transfers_vertical_scrolling_to_parent: bool, )
Setter for transfersVerticalScrollingToParent
.
pub unsafe fn showsVerticalScrollIndicator(&self) -> bool
Sourcepub unsafe fn setShowsVerticalScrollIndicator(
&self,
shows_vertical_scroll_indicator: bool,
)
pub unsafe fn setShowsVerticalScrollIndicator( &self, shows_vertical_scroll_indicator: bool, )
Setter for showsVerticalScrollIndicator
.
pub unsafe fn showsHorizontalScrollIndicator(&self) -> bool
Sourcepub unsafe fn setShowsHorizontalScrollIndicator(
&self,
shows_horizontal_scroll_indicator: bool,
)
pub unsafe fn setShowsHorizontalScrollIndicator( &self, shows_horizontal_scroll_indicator: bool, )
Setter for showsHorizontalScrollIndicator
.
pub unsafe fn indicatorStyle(&self) -> UIScrollViewIndicatorStyle
Sourcepub unsafe fn setIndicatorStyle(
&self,
indicator_style: UIScrollViewIndicatorStyle,
)
pub unsafe fn setIndicatorStyle( &self, indicator_style: UIScrollViewIndicatorStyle, )
Setter for indicatorStyle
.
pub unsafe fn indexDisplayMode(&self) -> UIScrollViewIndexDisplayMode
Sourcepub unsafe fn setIndexDisplayMode(
&self,
index_display_mode: UIScrollViewIndexDisplayMode,
)
pub unsafe fn setIndexDisplayMode( &self, index_display_mode: UIScrollViewIndexDisplayMode, )
Setter for indexDisplayMode
.
pub unsafe fn flashScrollIndicators(&self)
pub unsafe fn withScrollIndicatorsShownForContentOffsetChanges( &self, changes: &Block<dyn Fn() + '_>, )
pub unsafe fn isTracking(&self) -> bool
pub unsafe fn isDragging(&self) -> bool
pub unsafe fn isDecelerating(&self) -> bool
pub unsafe fn isScrollAnimating(&self) -> bool
pub unsafe fn delaysContentTouches(&self) -> bool
Sourcepub unsafe fn setDelaysContentTouches(&self, delays_content_touches: bool)
pub unsafe fn setDelaysContentTouches(&self, delays_content_touches: bool)
Setter for delaysContentTouches
.
pub unsafe fn canCancelContentTouches(&self) -> bool
Sourcepub unsafe fn setCanCancelContentTouches(
&self,
can_cancel_content_touches: bool,
)
pub unsafe fn setCanCancelContentTouches( &self, can_cancel_content_touches: bool, )
Setter for canCancelContentTouches
.
pub unsafe fn touchesShouldCancelInContentView(&self, view: &UIView) -> bool
pub unsafe fn bouncesZoom(&self) -> bool
Sourcepub unsafe fn setBouncesZoom(&self, bounces_zoom: bool)
pub unsafe fn setBouncesZoom(&self, bounces_zoom: bool)
Setter for bouncesZoom
.
pub unsafe fn isZooming(&self) -> bool
pub unsafe fn isZoomBouncing(&self) -> bool
pub unsafe fn isZoomAnimating(&self) -> bool
pub unsafe fn scrollsToTop(&self) -> bool
Sourcepub unsafe fn setScrollsToTop(&self, scrolls_to_top: bool)
pub unsafe fn setScrollsToTop(&self, scrolls_to_top: bool)
Setter for scrollsToTop
.
pub unsafe fn stopScrollingAndZooming(&self)
pub unsafe fn directionalPressGestureRecognizer( &self, ) -> Retained<UIGestureRecognizer>
pub unsafe fn keyboardDismissMode(&self) -> UIScrollViewKeyboardDismissMode
Sourcepub unsafe fn setKeyboardDismissMode(
&self,
keyboard_dismiss_mode: UIScrollViewKeyboardDismissMode,
)
pub unsafe fn setKeyboardDismissMode( &self, keyboard_dismiss_mode: UIScrollViewKeyboardDismissMode, )
Setter for keyboardDismissMode
.
Sourcepub unsafe fn allowsKeyboardScrolling(&self) -> bool
pub unsafe fn allowsKeyboardScrolling(&self) -> bool
Set this to YES to make the scroll view animate its content offset in response to keys like Page Up/Down, Home/End, and the arrow keys. The scroll view must be focused or first responder in order to receive these key events. Default is YES for apps linked after iOS 17.0.
Sourcepub unsafe fn setAllowsKeyboardScrolling(&self, allows_keyboard_scrolling: bool)
pub unsafe fn setAllowsKeyboardScrolling(&self, allows_keyboard_scrolling: bool)
Setter for allowsKeyboardScrolling
.
Methods from Deref<Target = UIView>§
pub unsafe fn addInteraction( &self, interaction: &ProtocolObject<dyn UIInteraction>, )
pub unsafe fn removeInteraction( &self, interaction: &ProtocolObject<dyn UIInteraction>, )
pub unsafe fn interactions( &self, ) -> Retained<NSArray<ProtocolObject<dyn UIInteraction>>>
Sourcepub unsafe fn setInteractions(
&self,
interactions: &NSArray<ProtocolObject<dyn UIInteraction>>,
)
pub unsafe fn setInteractions( &self, interactions: &NSArray<ProtocolObject<dyn UIInteraction>>, )
Setter for interactions
.
pub unsafe fn isUserInteractionEnabled(&self) -> bool
Sourcepub unsafe fn setUserInteractionEnabled(&self, user_interaction_enabled: bool)
pub unsafe fn setUserInteractionEnabled(&self, user_interaction_enabled: bool)
Setter for isUserInteractionEnabled
.
pub unsafe fn tag(&self) -> isize
pub unsafe fn canBecomeFocused(&self) -> bool
pub unsafe fn isFocused(&self) -> bool
Sourcepub unsafe fn focusGroupIdentifier(&self) -> Option<Retained<NSString>>
pub unsafe fn focusGroupIdentifier(&self) -> Option<Retained<NSString>>
The identifier of the focus group that this view belongs to. If this is nil, subviews inherit their superview’s focus group.
Sourcepub unsafe fn setFocusGroupIdentifier(
&self,
focus_group_identifier: Option<&NSString>,
)
pub unsafe fn setFocusGroupIdentifier( &self, focus_group_identifier: Option<&NSString>, )
Setter for focusGroupIdentifier
.
Sourcepub unsafe fn focusGroupPriority(&self) -> isize
pub unsafe fn focusGroupPriority(&self) -> isize
The priority this item has in its focus group. The higher the priority, the more likely it is to get picked when focus moves into this group. Note: this method can only be used to increase an item’s priority, not decrease it. For example if an item is currently selected, the actual priority of this item will be determined by MAX(focusGroupPriority, UIFocusGroupPrioritySelected).
Sourcepub unsafe fn setFocusGroupPriority(&self, focus_group_priority: isize)
pub unsafe fn setFocusGroupPriority(&self, focus_group_priority: isize)
Setter for focusGroupPriority
.
pub unsafe fn semanticContentAttribute(&self) -> UISemanticContentAttribute
Sourcepub unsafe fn setSemanticContentAttribute(
&self,
semantic_content_attribute: UISemanticContentAttribute,
)
pub unsafe fn setSemanticContentAttribute( &self, semantic_content_attribute: UISemanticContentAttribute, )
Setter for semanticContentAttribute
.
pub unsafe fn isMultipleTouchEnabled(&self) -> bool
Sourcepub fn setMultipleTouchEnabled(&self, multiple_touch_enabled: bool)
pub fn setMultipleTouchEnabled(&self, multiple_touch_enabled: bool)
Setter for isMultipleTouchEnabled
.
pub unsafe fn isExclusiveTouch(&self) -> bool
Sourcepub unsafe fn setExclusiveTouch(&self, exclusive_touch: bool)
pub unsafe fn setExclusiveTouch(&self, exclusive_touch: bool)
Setter for isExclusiveTouch
.
pub unsafe fn autoresizesSubviews(&self) -> bool
Sourcepub unsafe fn setAutoresizesSubviews(&self, autoresizes_subviews: bool)
pub unsafe fn setAutoresizesSubviews(&self, autoresizes_subviews: bool)
Setter for autoresizesSubviews
.
pub unsafe fn autoresizingMask(&self) -> UIViewAutoresizing
Sourcepub unsafe fn setAutoresizingMask(&self, autoresizing_mask: UIViewAutoresizing)
pub unsafe fn setAutoresizingMask(&self, autoresizing_mask: UIViewAutoresizing)
Setter for autoresizingMask
.
pub unsafe fn sizeToFit(&self)
pub fn superview(&self) -> Option<Retained<UIView>>
pub fn subviews(&self) -> Retained<NSArray<UIView>>
pub unsafe fn removeFromSuperview(&self)
pub unsafe fn insertSubview_atIndex(&self, view: &UIView, index: isize)
pub unsafe fn exchangeSubviewAtIndex_withSubviewAtIndex( &self, index1: isize, index2: isize, )
pub unsafe fn addSubview(&self, view: &UIView)
pub unsafe fn insertSubview_belowSubview( &self, view: &UIView, sibling_subview: &UIView, )
pub unsafe fn insertSubview_aboveSubview( &self, view: &UIView, sibling_subview: &UIView, )
pub unsafe fn bringSubviewToFront(&self, view: &UIView)
pub unsafe fn sendSubviewToBack(&self, view: &UIView)
pub unsafe fn didAddSubview(&self, subview: &UIView)
pub unsafe fn willRemoveSubview(&self, subview: &UIView)
pub unsafe fn willMoveToSuperview(&self, new_superview: Option<&UIView>)
pub unsafe fn didMoveToSuperview(&self)
pub unsafe fn didMoveToWindow(&self)
pub unsafe fn isDescendantOfView(&self, view: &UIView) -> bool
pub unsafe fn viewWithTag(&self, tag: isize) -> Option<Retained<UIView>>
pub unsafe fn setNeedsLayout(&self)
pub unsafe fn layoutIfNeeded(&self)
pub unsafe fn layoutSubviews(&self)
pub unsafe fn preservesSuperviewLayoutMargins(&self) -> bool
Sourcepub unsafe fn setPreservesSuperviewLayoutMargins(
&self,
preserves_superview_layout_margins: bool,
)
pub unsafe fn setPreservesSuperviewLayoutMargins( &self, preserves_superview_layout_margins: bool, )
Setter for preservesSuperviewLayoutMargins
.
pub unsafe fn insetsLayoutMarginsFromSafeArea(&self) -> bool
Sourcepub unsafe fn setInsetsLayoutMarginsFromSafeArea(
&self,
insets_layout_margins_from_safe_area: bool,
)
pub unsafe fn setInsetsLayoutMarginsFromSafeArea( &self, insets_layout_margins_from_safe_area: bool, )
Setter for insetsLayoutMarginsFromSafeArea
.
pub unsafe fn layoutMarginsDidChange(&self)
pub unsafe fn safeAreaInsetsDidChange(&self)
pub fn setNeedsDisplay(&self)
pub unsafe fn clipsToBounds(&self) -> bool
Sourcepub unsafe fn setClipsToBounds(&self, clips_to_bounds: bool)
pub unsafe fn setClipsToBounds(&self, clips_to_bounds: bool)
Setter for clipsToBounds
.
pub fn backgroundColor(&self) -> Option<Retained<UIColor>>
Sourcepub fn setBackgroundColor(&self, background_color: Option<&UIColor>)
pub fn setBackgroundColor(&self, background_color: Option<&UIColor>)
Setter for backgroundColor
.
pub unsafe fn isOpaque(&self) -> bool
pub unsafe fn clearsContextBeforeDrawing(&self) -> bool
Sourcepub unsafe fn setClearsContextBeforeDrawing(
&self,
clears_context_before_drawing: bool,
)
pub unsafe fn setClearsContextBeforeDrawing( &self, clears_context_before_drawing: bool, )
Setter for clearsContextBeforeDrawing
.
pub fn isHidden(&self) -> bool
pub unsafe fn contentMode(&self) -> UIViewContentMode
Sourcepub unsafe fn setContentMode(&self, content_mode: UIViewContentMode)
pub unsafe fn setContentMode(&self, content_mode: UIViewContentMode)
Setter for contentMode
.
pub unsafe fn maskView(&self) -> Option<Retained<UIView>>
Sourcepub unsafe fn setMaskView(&self, mask_view: Option<&UIView>)
pub unsafe fn setMaskView(&self, mask_view: Option<&UIView>)
Setter for maskView
.
pub unsafe fn tintColor(&self) -> Option<Retained<UIColor>>
Sourcepub unsafe fn setTintColor(&self, tint_color: Option<&UIColor>)
pub unsafe fn setTintColor(&self, tint_color: Option<&UIColor>)
Setter for tintColor
.
pub unsafe fn tintAdjustmentMode(&self) -> UIViewTintAdjustmentMode
Sourcepub unsafe fn setTintAdjustmentMode(
&self,
tint_adjustment_mode: UIViewTintAdjustmentMode,
)
pub unsafe fn setTintAdjustmentMode( &self, tint_adjustment_mode: UIViewTintAdjustmentMode, )
Setter for tintAdjustmentMode
.
pub unsafe fn tintColorDidChange(&self)
pub fn gestureRecognizers( &self, ) -> Option<Retained<NSArray<UIGestureRecognizer>>>
Sourcepub unsafe fn setGestureRecognizers(
&self,
gesture_recognizers: Option<&NSArray<UIGestureRecognizer>>,
)
pub unsafe fn setGestureRecognizers( &self, gesture_recognizers: Option<&NSArray<UIGestureRecognizer>>, )
Setter for gestureRecognizers
.
pub fn addGestureRecognizer(&self, gesture_recognizer: &UIGestureRecognizer)
pub fn removeGestureRecognizer(&self, gesture_recognizer: &UIGestureRecognizer)
pub fn gestureRecognizerShouldBegin( &self, gesture_recognizer: &UIGestureRecognizer, ) -> bool
pub unsafe fn updateConstraintsIfNeeded(&self)
pub unsafe fn updateConstraints(&self)
pub unsafe fn needsUpdateConstraints(&self) -> bool
pub unsafe fn setNeedsUpdateConstraints(&self)
pub unsafe fn translatesAutoresizingMaskIntoConstraints(&self) -> bool
Sourcepub unsafe fn setTranslatesAutoresizingMaskIntoConstraints(
&self,
translates_autoresizing_mask_into_constraints: bool,
)
pub unsafe fn setTranslatesAutoresizingMaskIntoConstraints( &self, translates_autoresizing_mask_into_constraints: bool, )
Setter for translatesAutoresizingMaskIntoConstraints
.
pub unsafe fn viewForBaselineLayout(&self) -> Retained<UIView>
pub unsafe fn viewForFirstBaselineLayout(&self) -> Retained<UIView>
pub unsafe fn viewForLastBaselineLayout(&self) -> Retained<UIView>
pub unsafe fn invalidateIntrinsicContentSize(&self)
pub unsafe fn hasAmbiguousLayout(&self) -> bool
pub unsafe fn exerciseAmbiguityInLayout(&self)
pub unsafe fn restorationIdentifier(&self) -> Option<Retained<NSString>>
Sourcepub unsafe fn setRestorationIdentifier(
&self,
restoration_identifier: Option<&NSString>,
)
pub unsafe fn setRestorationIdentifier( &self, restoration_identifier: Option<&NSString>, )
Setter for restorationIdentifier
.
pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder)
pub unsafe fn decodeRestorableStateWithCoder(&self, coder: &NSCoder)
pub unsafe fn snapshotViewAfterScreenUpdates( &self, after_updates: bool, ) -> Option<Retained<UIView>>
Sourcepub unsafe fn appliedContentSizeCategoryLimitsDescription(
&self,
) -> Retained<NSString>
pub unsafe fn appliedContentSizeCategoryLimitsDescription( &self, ) -> Retained<NSString>
Will return a string with a log of all the superviews of this view, alongside with what content size category each view has and if that view has limits applied. This is for debugging purposes only.
pub unsafe fn traitOverrides( &self, ) -> Retained<ProtocolObject<dyn UITraitOverrides>>
Sourcepub unsafe fn updateTraitsIfNeeded(&self)
pub unsafe fn updateTraitsIfNeeded(&self)
Forces an immediate trait update for this view (and its view controller, if applicable) and any subviews, including any view controllers or views in its subtree. Any trait change callbacks are sent synchronously.
Methods from Deref<Target = UIResponder>§
pub unsafe fn nextResponder(&self) -> Option<Retained<UIResponder>>
pub unsafe fn canBecomeFirstResponder(&self) -> bool
pub unsafe fn becomeFirstResponder(&self) -> bool
pub unsafe fn canResignFirstResponder(&self) -> bool
pub unsafe fn resignFirstResponder(&self) -> bool
pub unsafe fn isFirstResponder(&self) -> bool
pub unsafe fn canPerformAction_withSender( &self, action: Sel, sender: Option<&AnyObject>, ) -> bool
pub unsafe fn targetForAction_withSender( &self, action: Sel, sender: Option<&AnyObject>, ) -> Option<Retained<AnyObject>>
pub unsafe fn undoManager(&self) -> Option<Retained<NSUndoManager>>
pub unsafe fn editingInteractionConfiguration( &self, ) -> UIEditingInteractionConfiguration
pub unsafe fn inputView(&self) -> Option<Retained<UIView>>
pub unsafe fn inputAccessoryView(&self) -> Option<Retained<UIView>>
Sourcepub unsafe fn inputAssistantItem(&self) -> Retained<UITextInputAssistantItem>
pub unsafe fn inputAssistantItem(&self) -> Retained<UITextInputAssistantItem>
This method is for clients that wish to put buttons on the Shortcuts Bar, shown on top of the keyboard. You may modify the returned inputAssistantItem to add to or replace the existing items on the bar. Modifications made to the returned UITextInputAssistantItem are reflected automatically. This method should not be overridden. Goes up the responder chain.
pub unsafe fn textInputMode(&self) -> Option<Retained<UITextInputMode>>
pub unsafe fn textInputContextIdentifier(&self) -> Option<Retained<NSString>>
pub unsafe fn reloadInputViews(&self)
pub unsafe fn userActivity(&self) -> Option<Retained<NSUserActivity>>
Sourcepub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)
pub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>)
Setter for userActivity
.
pub unsafe fn updateUserActivityState(&self, activity: &NSUserActivity)
pub unsafe fn restoreUserActivityState(&self, activity: &NSUserActivity)
pub unsafe fn captureTextFromCamera(&self, sender: Option<&AnyObject>)
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for BEScrollView
impl AsRef<AnyObject> for BEScrollView
Source§impl AsRef<BEScrollView> for BEScrollView
impl AsRef<BEScrollView> for BEScrollView
Source§impl AsRef<NSObject> for BEScrollView
impl AsRef<NSObject> for BEScrollView
Source§impl AsRef<UIResponder> for BEScrollView
impl AsRef<UIResponder> for BEScrollView
Source§fn as_ref(&self) -> &UIResponder
fn as_ref(&self) -> &UIResponder
Source§impl AsRef<UIScrollView> for BEScrollView
impl AsRef<UIScrollView> for BEScrollView
Source§fn as_ref(&self) -> &UIScrollView
fn as_ref(&self) -> &UIScrollView
Source§impl AsRef<UIView> for BEScrollView
impl AsRef<UIView> for BEScrollView
Source§impl Borrow<AnyObject> for BEScrollView
impl Borrow<AnyObject> for BEScrollView
Source§impl Borrow<NSObject> for BEScrollView
impl Borrow<NSObject> for BEScrollView
Source§impl Borrow<UIResponder> for BEScrollView
impl Borrow<UIResponder> for BEScrollView
Source§fn borrow(&self) -> &UIResponder
fn borrow(&self) -> &UIResponder
Source§impl Borrow<UIScrollView> for BEScrollView
impl Borrow<UIScrollView> for BEScrollView
Source§fn borrow(&self) -> &UIScrollView
fn borrow(&self) -> &UIScrollView
Source§impl Borrow<UIView> for BEScrollView
impl Borrow<UIView> for BEScrollView
Source§impl CALayerDelegate for BEScrollView
impl CALayerDelegate for BEScrollView
unsafe fn displayLayer(&self, layer: &CALayer)
unsafe fn layerWillDraw(&self, layer: &CALayer)
unsafe fn layoutSublayersOfLayer(&self, layer: &CALayer)
unsafe fn actionForLayer_forKey( &self, layer: &CALayer, event: &NSString, ) -> Option<Retained<ProtocolObject<dyn CAAction>>>
Source§impl ClassType for BEScrollView
impl ClassType for BEScrollView
Source§const NAME: &'static str = "BEScrollView"
const NAME: &'static str = "BEScrollView"
Source§type Super = UIScrollView
type Super = UIScrollView
Source§type ThreadKind = dyn MainThreadOnly
type ThreadKind = dyn MainThreadOnly
Source§impl Debug for BEScrollView
impl Debug for BEScrollView
Source§impl Deref for BEScrollView
impl Deref for BEScrollView
Source§impl Hash for BEScrollView
impl Hash for BEScrollView
Source§impl Message for BEScrollView
impl Message for BEScrollView
Source§impl NSCoding for BEScrollView
impl NSCoding for BEScrollView
Source§impl NSObjectProtocol for BEScrollView
impl NSObjectProtocol for BEScrollView
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref
Source§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Source§impl PartialEq for BEScrollView
impl PartialEq for BEScrollView
Source§impl RefEncode for BEScrollView
impl RefEncode for BEScrollView
Source§const ENCODING_REF: Encoding = <UIScrollView as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <UIScrollView as ::objc2::RefEncode>::ENCODING_REF
Source§impl UIAppearance for BEScrollView
impl UIAppearance for BEScrollView
unsafe fn appearance(mtm: MainThreadMarker) -> Retained<Self>
unsafe fn appearanceWhenContainedInInstancesOfClasses( container_types: &NSArray<AnyClass>, mtm: MainThreadMarker, ) -> Retained<Self>
unsafe fn appearanceForTraitCollection( trait: &UITraitCollection, mtm: MainThreadMarker, ) -> Retained<Self>
unsafe fn appearanceForTraitCollection_whenContainedInInstancesOfClasses( trait: &UITraitCollection, container_types: &NSArray<AnyClass>, mtm: MainThreadMarker, ) -> Retained<Self>
Source§impl UIDynamicItem for BEScrollView
impl UIDynamicItem for BEScrollView
Source§unsafe fn collisionBoundsType(&self) -> UIDynamicItemCollisionBoundsType
unsafe fn collisionBoundsType(&self) -> UIDynamicItemCollisionBoundsType
Source§impl UIFocusEnvironment for BEScrollView
impl UIFocusEnvironment for BEScrollView
Source§unsafe fn preferredFocusEnvironments(
&self,
) -> Retained<NSArray<ProtocolObject<dyn UIFocusEnvironment>>>
unsafe fn preferredFocusEnvironments( &self, ) -> Retained<NSArray<ProtocolObject<dyn UIFocusEnvironment>>>
Source§unsafe fn parentFocusEnvironment(
&self,
) -> Option<Retained<ProtocolObject<dyn UIFocusEnvironment>>>
unsafe fn parentFocusEnvironment( &self, ) -> Option<Retained<ProtocolObject<dyn UIFocusEnvironment>>>
Source§unsafe fn focusItemContainer(
&self,
) -> Option<Retained<ProtocolObject<dyn UIFocusItemContainer>>>
unsafe fn focusItemContainer( &self, ) -> Option<Retained<ProtocolObject<dyn UIFocusItemContainer>>>
Source§unsafe fn setNeedsFocusUpdate(&self)
unsafe fn setNeedsFocusUpdate(&self)
[[UIFocusSystem focusSystemForEnvironment:self] requestFocusUpdateToEnvironment:self]
;Source§unsafe fn updateFocusIfNeeded(&self)
unsafe fn updateFocusIfNeeded(&self)
[[UIFocusSystem focusSystemForEnvironment:self] updateFocusIfNeeded];
.Source§unsafe fn shouldUpdateFocusInContext(
&self,
context: &UIFocusUpdateContext,
) -> bool
unsafe fn shouldUpdateFocusInContext( &self, context: &UIFocusUpdateContext, ) -> bool
Source§unsafe fn soundIdentifierForFocusUpdateInContext(
&self,
context: &UIFocusUpdateContext,
) -> Option<Retained<NSString>>
unsafe fn soundIdentifierForFocusUpdateInContext( &self, context: &UIFocusUpdateContext, ) -> Option<Retained<NSString>>
Source§impl UIFocusItem for BEScrollView
impl UIFocusItem for BEScrollView
Source§unsafe fn canBecomeFocused(&self) -> bool
unsafe fn canBecomeFocused(&self) -> bool
Source§unsafe fn focusGroupPriority(&self) -> isize
unsafe fn focusGroupPriority(&self) -> isize
Source§unsafe fn focusItemDeferralMode(&self) -> UIFocusItemDeferralMode
unsafe fn focusItemDeferralMode(&self) -> UIFocusItemDeferralMode
UIFocusItemDeferralModeNever
, the focus deferral will not be enabled again
after the user engagement timeout has expired if this item is currently focused and programmatic focus updates pointing
to this item will be executed immediatly. If it returns UIFocusItemDeferralModeAlways
focus will always be deferred
when this item is supposed to be focused.
Does nothing when focus deferral is not supported on the platform.Source§unsafe fn isTransparentFocusItem(&self) -> bool
unsafe fn isTransparentFocusItem(&self) -> bool
Source§impl UIFocusItemContainer for BEScrollView
impl UIFocusItemContainer for BEScrollView
Source§unsafe fn coordinateSpace(
&self,
) -> Retained<ProtocolObject<dyn UICoordinateSpace>>
unsafe fn coordinateSpace( &self, ) -> Retained<ProtocolObject<dyn UICoordinateSpace>>
Source§impl UIResponderStandardEditActions for BEScrollView
impl UIResponderStandardEditActions for BEScrollView
unsafe fn cut(&self, sender: Option<&AnyObject>)
unsafe fn copy(&self, sender: Option<&AnyObject>)
unsafe fn paste(&self, sender: Option<&AnyObject>)
unsafe fn pasteAndMatchStyle(&self, sender: Option<&AnyObject>)
unsafe fn pasteAndGo(&self, sender: Option<&AnyObject>)
unsafe fn pasteAndSearch(&self, sender: Option<&AnyObject>)
unsafe fn select(&self, sender: Option<&AnyObject>)
unsafe fn selectAll(&self, sender: Option<&AnyObject>)
unsafe fn delete(&self, sender: Option<&AnyObject>)
unsafe fn makeTextWritingDirectionLeftToRight(&self, sender: Option<&AnyObject>)
unsafe fn makeTextWritingDirectionRightToLeft(&self, sender: Option<&AnyObject>)
unsafe fn toggleBoldface(&self, sender: Option<&AnyObject>)
unsafe fn toggleItalics(&self, sender: Option<&AnyObject>)
unsafe fn toggleUnderline(&self, sender: Option<&AnyObject>)
unsafe fn increaseSize(&self, sender: Option<&AnyObject>)
unsafe fn decreaseSize(&self, sender: Option<&AnyObject>)
unsafe fn find(&self, sender: Option<&AnyObject>)
unsafe fn findAndReplace(&self, sender: Option<&AnyObject>)
unsafe fn findNext(&self, sender: Option<&AnyObject>)
unsafe fn findPrevious(&self, sender: Option<&AnyObject>)
unsafe fn useSelectionForFind(&self, sender: Option<&AnyObject>)
unsafe fn updateTextAttributesWithConversionHandler( &self, conversion_handler: *mut Block<dyn Fn(NonNull<NSDictionary<NSString>>) -> NonNull<NSDictionary<NSString>>>, )
unsafe fn print(&self, sender: Option<&AnyObject>)
unsafe fn rename(&self, sender: Option<&AnyObject>)
unsafe fn duplicate(&self, sender: Option<&AnyObject>)
unsafe fn move(&self, sender: Option<&AnyObject>)
unsafe fn export(&self, sender: Option<&AnyObject>)
unsafe fn showWritingTools(&self, sender: &AnyObject)
Source§impl UITraitEnvironment for BEScrollView
impl UITraitEnvironment for BEScrollView
fn traitCollection(&self) -> Retained<UITraitCollection>
Source§unsafe fn traitCollectionDidChange(
&self,
previous_trait_collection: Option<&UITraitCollection>,
)
unsafe fn traitCollectionDidChange( &self, previous_trait_collection: Option<&UITraitCollection>, )
impl DowncastTarget for BEScrollView
impl Eq for BEScrollView
impl UIAppearanceContainer for BEScrollView
impl UICoordinateSpace for BEScrollView
impl UIFocusItemScrollableContainer for BEScrollView
Auto Trait Implementations§
impl !Freeze for BEScrollView
impl !RefUnwindSafe for BEScrollView
impl !Send for BEScrollView
impl !Sync for BEScrollView
impl !Unpin for BEScrollView
impl !UnwindSafe for BEScrollView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'a, T> MainThreadOnly for T
impl<'a, T> MainThreadOnly for T
Source§fn mtm(&self) -> MainThreadMarker
fn mtm(&self) -> MainThreadMarker
MainThreadMarker
from the main-thread-only object. Read more