ZBarReadView我有一個從故事板創建的300 * 90像素,它顯示爲大約200 * 400像素,因爲ZBarReaderView不佔用它的大小太嚴重......ZBar從StoryBoard的自定義大小,但當它被調用,它的大小是不是我設置
我宣佈我的IBOutlets像這樣:
@interface MYQViewController : UIViewController <ZBarReaderViewDelegate>
{
ZBarReaderView *readerView;
ZBarCameraSimulator *cameraSim;
UITextView *resultText;
}
@property (strong, nonatomic) IBOutlet ZBarReaderView *readerView;
@property (strong, nonatomic) IBOutlet UITextView *resultText;
@end
在viewDidLoad中
-(void) viewDidLoad
{
readerView.readerDelegate = self;
readerView.zoom=1;
if(TAGET_IPONE_SIMULATOR)
{
cameraSim=[[ZBarCameraSimulator alloc] initWithViewController:self];
cameraSim.readerView=readerView;
}
}
-(void)Scan
{
if(readerView.hidden)
{
[readerView start];
readerView.hidden = NO;
resultText.text=EMPTY_STRING;
}
else
{
[readerView stop];
readerView.hidden = YES;
//OTHER CODES
}
}
-(void) readerView:(ZBarReaderView *)readerView didReadSymbols:(ZBarSymbolSet *)symbolsfromImage:(UIImage *)image
{
for (ZBarSymol *sym in symbols)
{
self.resultText.text=sym.data;
break;
}
}
請詳細解釋並添加代碼段。 – Habibillah
我已更新代碼,請幫助我。 –