Ios 使用nsrunlop阻止程序在模拟器上运行,但在设备上失败
这里我有一个UIAlertView,它出现在nsrunlop中,我希望在它出现时阻止程序继续运行,单击“确定”按钮后,程序继续运行。我尝试了两种方法 1.在我的LBAlertView.h中Ios 使用nsrunlop阻止程序在模拟器上运行,但在设备上失败,ios,objective-c,Ios,Objective C,这里我有一个UIAlertView,它出现在nsrunlop中,我希望在它出现时阻止程序继续运行,单击“确定”按钮后,程序继续运行。我尝试了两种方法 1.在我的LBAlertView.h中 @interface LBAlertView : UIAlertView <UIAlertViewDelegate> { BOOL isWaiting4Tap; } @property(nonatomic,assign) BOOL isWaiting4Tap; - (void)show
@interface LBAlertView : UIAlertView <UIAlertViewDelegate>
{
BOOL isWaiting4Tap;
}
@property(nonatomic,assign) BOOL isWaiting4Tap;
- (void)showModal;
@end
在代表处
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (alertView.tag) {
case 0:
{
self.tipView.isWaiting4Tap = 0;
[((LBSceneView*)self.delegate).theBall initBall];
}
break;
default:
break;
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (alertView.tag) {
case 0:
{
CFRunLoopStop(CFRunLoopGetCurrent());
[((LBSceneView*)self.delegate).theBall initBall];
}
break;
default:
break;
}
}
其中tipView是LBAlertView的对象
2.在LBAlertView.m中
- (void)showModal
{
isWaiting4Tap = YES;
[self show];
while (self.isWaiting4Tap)
{
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate
distantFuture]];
}
}
- (void)showModal
{
[self show];
CFRunLoopRun();
}
在代表处
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (alertView.tag) {
case 0:
{
self.tipView.isWaiting4Tap = 0;
[((LBSceneView*)self.delegate).theBall initBall];
}
break;
default:
break;
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (alertView.tag) {
case 0:
{
CFRunLoopStop(CFRunLoopGetCurrent());
[((LBSceneView*)self.delegate).theBall initBall];
}
break;
default:
break;
}
}
这两种方法在模拟器上都很好,但在设备上都失败了,LBAlertView一次又一次弹出,似乎程序根本没有被阻止,有人能找出原因吗,谢谢这太疯狂了。只需调用委托内的延续逻辑。请在此处为我们提供帮助的原因:)这不是我们在iOSwhy中经常使用的模式,我认为这是常见的解决方案,那么如何在出现uialertview时阻止nsrunlop呢?