我和iBeaconss
一起玩,现在设置我的代码,这样当我输入信标时我会收到一个弹出窗口(下面是代码)。问题我现在遇到它不断弹出。
现在有人如何设置我的代码,所以当我进入某个地区时我只收到一次?
此致
马克
if ([[NSString stringWithFormat:@"%@", beacon.minor] isEqualToString:@"51447"])
//hiermee kun je een pop-op geven met of hij wel of niet naar tweede scherm wil.
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"Open second screen?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alertView show];
}
答案 0 :(得分:1)
只需记住它使用BOOL或字典(多个
)if ([[NSString stringWithFormat:@"%@", beacon.minor] isEqualToString:@"51447"])
//hiermee kun je een pop-op geven met of hij wel of niet naar tweede scherm wil.
{
if(![_shownRanges[@"51447"] boolValue]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"Open second screen?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alertView show];
if(!_shownRanges) {
_shownRanges = [NSMutableDictionary dictionary];
}
_shownRanges[@"51447"] = @YES;
}
}
(_ shownRanges是您在界面中定义的NSMutableDictionary)