我有一个带有表格和一个按钮的主页,按下我的按钮我将加载 qrCode 阅读器视图,我想在扫描条形码后隐藏我的 qrCode 视图,
你能给我一些提示吗?最好的方法是什么?NSNOtification 或......以及如何?
提前致谢!
这是我的二维码扫描代码:
- (void) readerView:(ZBarReaderView *)readerView didReadSymbols: (ZBarSymbolSet *)symbols
fromImage:(UIImage *)image
{
ZBarSymbol * s = nil;
for (s in symbols)
{
image_view.image = image;
// 这里我会去httpReq类的addStamp方法
[[HttpReq sharedHttp] setCode:s.data];
[[HttpReq sharedHttp] addStamp];
}
}
这是我的 addStamp 方法,我必须在此方法中隐藏视图:
-(void) addStamp
{
// My code was here for connect to api
NSError *jsonError;
NSDictionary* dic = [NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&jsonError];
if(jsonError != nil)
{
return;
}
// I want to do it here when I have a success or not
BOOL success = [[dic objectForKey:@"success"] boolValue];
if(success){
[self addStampInDB:[[dic objectForKey:@"cardId"] intValue]];
}else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[dic
objectForKey:@"error"]
delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert performSelectorOnMainThread:@selector(show) withObject:nil
waitUntilDone:NO];
}
}];
}