ios - Using NSRunLoop to block proceeding works on Simulator but fail on device -
here have uialertview,it appears within nsrunloop, want program proceeding blocked when appears, after clicked "ok" button, program carries on. tried 2 methods
1.in lbalertview.h
@interface lbalertview : uialertview <uialertviewdelegate> { bool iswaiting4tap; } @property(nonatomic,assign) bool iswaiting4tap; - (void)showmodal; @end
in lbalertview.m
- (void)showmodal { iswaiting4tap = yes; [self show]; while (self.iswaiting4tap) { [[nsrunloop currentrunloop] runmode:nsdefaultrunloopmode beforedate:[nsdate distantfuture]]; } }
in delegate place
- (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { switch (alertview.tag) { case 0: { self.tipview.iswaiting4tap = 0; [((lbsceneview*)self.delegate).theball initball]; } break; default: break; } }
where tipview object of lbalertview.
2.in lbalertview.m
- (void)showmodal { [self show]; cfrunlooprun(); }
in delegate place
- (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { switch (alertview.tag) { case 0: { cfrunloopstop(cfrunloopgetcurrent()); [((lbsceneview*)self.delegate).theball initball]; } break; default: break; } }
both methods works on simulator fails on device, lbalertview pops out on , on again, seems program not blocked @ all, can figure out why, thanks
Comments
Post a Comment