1

私はiPhoneとObjective-Cの開発に不慣れです。

カメラが写真を撮った後、ビュー(XIBファイル)を変更する方法を知りたいです。

誰かが私を助けたり、コードを共有したりできますか?私は1週間からこれを探しています:(アプリを終了した後、プロジェクトを共有したり、チュートリアルを作成したりする準備ができています。

アプリに関する情報:バーコードをスキャンしてアプリに保存したい。ZBarSDKを使用してバーコードをスキャンする場合。私はTabBarControllerを持っています、最初のタブで、私はカメラを開くことができます。スキャンプロセスの後、2番目のタブ(別のXIBファイル)にジャンプして結果を表示したいと思います。

助けてくれてありがとう。

ここに最初のタブ(ScanCodeViewController)の私のコードがあります:

.h

#import < UIKit/UIKit.h >

@class OutPutCodeViewController;

@interface ScanCodeViewController : UIViewController <ZBarReaderDelegate> {
 IBOutlet UIImageView *img;
 OutPutCodeViewController *output;         
}


@property (nonatomic, retain) IBOutlet UIImageView *img;
@property (nonatomic, retain) OutPutCodeViewController *output;

- (IBAction) scanButton;

@end

.m

#import "ScanCodeViewController.h"


@implementation ScanCodeViewController

@synthesize img;
@synthesize output;


- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
[img release];
[super dealloc];
}


- (IBAction) scanButton {
 NSLog(@"Scanbutton wurde geklickt!");

 ZBarReaderViewController *reader = [ZBarReaderViewController new];
 reader.readerDelegate = self;

 ZBarImageScanner *scanner = reader.scanner;

 [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];

 [self presentModalViewController:reader animated: YES];
 [reader release];
 }


- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{
 NSLog(@"Entered imagePickerController");


 // ADD: get the decode results
 id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
 ZBarSymbol *symbol = nil;
 for(symbol in results) {
 break;
 }

 img.image = [info objectForKey:UIImagePickerControllerOriginalImage];
 [reader dismissModalViewControllerAnimated: YES];


 //[self presentModalViewController:output animated:YES]; //by using this, app chrashes 

}


- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
 [picker dismissModalViewControllerAnimated: YES];

}


@end  

そしてここにSecongタブ(OutPutCodeViewController)

.h

#import <UIKit/UIKit.h>


@interface OutPutCodeViewController : UIViewController {
 IBOutlet UIImageView *resultImage;
 IBOutlet UITextField *resultText;
}

@property (nonatomic, retain) IBOutlet UIImageView *resultImage;
@property (nonatomic, retain) IBOutlet UITextField *resultText;


@end

.m

#import "OutPutCodeViewController.h"


@implementation OutPutCodeViewController

@synthesize resultImage;
@synthesize resultText;


- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


- (void)dealloc {
 [resultImage release];
 [resultText release];

[super dealloc];
}


@end
4

2 に答える 2

3

とった!

animate:YES をこれ以上設定することはできません。これがサンプルと正しいコードです。

他の人に役立つことを願っています。

- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{

    // ADD: get the decode results
    id<NSFastEnumeration> results =
    [info objectForKey: ZBarReaderControllerResults];
    ZBarSymbol *symbol = nil;
    for(symbol in results)
        break;

[reader dismissModalViewControllerAnimated: NO];

    TableDetailViewController *tc = [[TableDetailViewController alloc]         initWithNibName:@"TableDetailViewController" bundle:nil];
    tc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:tc animated:YES];
    [tc release];   

}

ブラシ51

于 2011-01-03T09:32:48.157 に答える
0

で、2 番目のタブに切り替えるためにdidFinishPickingMediaWithInfo呼び出す必要があります。[self.tabBarController setSelectedIndex:1]

于 2010-12-30T11:16:49.003 に答える