ios - UIView added as an UIWindow subview doesn't respond to taps -


i've added uiview containing uitapgesturerecognizer key window's subview. shows properly, when tap view, target method not fired. i've tried replace gesture recognizer uibutton, still no avail.

here code.

notificationview.h

#import <uikit/uikit.h>  typedef ns_enum(int, notificationkind) {     notificationkindactivity,     notificationkindreply, };  @interface notificationview : uiview {      notificationkind currentnotificationkind;  }  -(id)initwithmessage:(nsstring*)message andcolor:(uicolor*)color andkind:(notificationkind)kind; -(void)show;  @end 

notificationview.m

#import "notificationview.h"  @implementation notificationview  - (id)initwithmessage:(nsstring*)message andcolor:(uicolor*)color andkind:(notificationkind)kind {     self = [super initwithframe:cgrectmake(0, 0, cgrectgetwidth([uiscreen mainscreen].bounds), 60)];     if (self) {         // initialization code         [self setalpha:0];         [self setbackgroundcolor:color];         [self setuserinteractionenabled:yes];           currentnotificationkind = kind;          uilabel *label = [[uilabel alloc] initwithframe:self.bounds];         [label setnumberoflines:0];         [label setfont:[uifont fontwithname:@"roboto-italic" size:20]];         [label settextcolor:[uicolor whitecolor]];         [label settextalignment:nstextalignmentcenter];         [label setpreferredmaxlayoutwidth:290];         [label settext:message];         [label setuserinteractionenabled:yes];         [self addsubview:label];          uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(notificationtapped)];         [tap setnumberoftapsrequired:1];         [self addgesturerecognizer:tap];          [[[uiapplication sharedapplication] keywindow] addsubview:self];      }     return self; }  -(void)show{     [uiview animatewithduration:0.3 animations:^{          [self setalpha:1];      } completion:^(bool finished) {          [uiview animatewithduration:0.3 delay:3 options:uiviewanimationoptioncurvelinear animations:^{             [self setalpha:0];          } completion:^(bool finished) {             [self removefromsuperview];         }];      }]; }  -(void)notificationtapped{      ddlogdebug(@"notification tapped!");  }  @end 

when happens me it's because screwed uiview frame. see content expected because uiview isn't clipping bounds, can't interact because taps outside bounds of uiview.

my simple test change background color of uiview , see if covers area expect or if screwed size/placement somehow.

i used pound head against wall issue, struggling hours, i've done many times it's 5min fix of "oh again".

edit:

then i'd @ show code. calling code isn't here, if i'm assume using show code , view on screen 3 seconds, that's problem.

as justin mentioned (comment above) , apple's docs

during animation, user interactions temporarily disabled views involved in animation, regardless of value in property. can disable behavior specifying uiviewanimationoptionallowuserinteraction option when configuring animation.

since entire time view on screen it's part of animation block, interaction disable entire time it's visible. i've never quite tested delay bit , whether animation disabled during piece, not surprise me animation disabled during delay. second animation still inside primary animation block, i'd assume animations blocked until both complete.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -