In the demo, found UITableViewCell
in the UIButton
short press once do not see the default effect of gray, stay a little longer to become gray, such as the official Twitter client profile picture, Weibo review like the three buttons. Weibo all kinds of client's avatar and other buttons also like this, the avatar is a lot of direct imageview plus gestures. The best thing to do with this detail is that Instagram does not have a short press of a long press, so it's a hit.
&NBSP was learned after a search; uitableview
as Uiscrollview
subclass, with Delayscontenttouches
's Boolean property, and Defaults to YES
, which is deferred response Uiscrollview
An event in a child view that, in this short delay, responds as a scrolling event if the touch has moved, and if it is not moved and has in the child view, the uicontrol
Type is immediately passed and the corresponding event is triggered when the touch position is in the control. So when &NBSP is pressed, UIButton
is passed to the child view control before the system determines that it is not a scrolling event, but the animation of the highlight effect is bypassed and the event is passed directly. So only when the finger stays a little longer, the delay time is spent to see the highlight effect.
UIButton
This delay is removed if you want the highlight effect to be displayed in a short press of a long press. Replace the default value with the following code in the place where you finished creating the table view object, or its initialization method NO
.
Sometableviewobject.delayscontenttouches = NO;
But this time again, when the finger is in the UIButton
area as the starting point of the scrolling operation, UIScrollView
it does not respond to the scrolling gesture.
If you want to UITableView
always respond to scrolling events in all places, you need to subclass UITableView
and rewrite the following methods that inherit from the parent class UIScrollView
.
Default returns YES if view isn ' t a uicontrol//returns whether to cancel touches related to the content Subview and St Art dragging.-(BOOL) Touchesshouldcancelincontentview: (UIView *) view{//Even if the touch is a Uicontrol (subclass: UIButton), we also want to drag Can cancel the action to respond to the scrolling action return YES;}
The UIScrollView
comments in the header file, as well as the description of Apple's official documentation, are known because it defaults to a scrolling event if the event is UIControl
returned in response to or its subclasses, even if the NO
touch is moved. So let it always return YES
, that is, UIScrollView
touch events that appear anywhere on the screen, and can respond to scrolling events if a move occurs.
UITableViewCell
structural changes in IOS 7
IOS 6 <UITableViewCell> | <uitableviewcellcontentview>//IOS 7 <UITableViewCell> | <UITableViewCellScrollView> | | <UITableViewCellContentView>
ios 7 Uitableviewcellcontentview
One more parent view Uitableviewcellscrollview
, See names with ScrollView
, But it doesn't seem like there's more than one level of event response delay .
If you write it wrong, UITableViewCellScrollView
you need to remove the delay.
I am doing the processing in the initialization method of the cell for (UIView *currentview in self.subviews) {if ([Nsstringfromclass ([CurrentView class]) Isequalt ostring:@ "Uitableviewcellscrollview"]) {Uiscrollview *SV = (Uiscrollview *) CurrentView; [SV Setdelayscontenttouches:no]; Break }}
"IOS" for UIButton short Press in Table View row cell Contentview does not produce a highlight effect