1

私はiphoneとobjective-c開発の新機能です。imagePickerController:didFinishPickingMediaWithInfoの後にビュー(XIB)を変更するには?

カメラが画像を撮影した後、どのようにビュー(XIBファイル)を変更できるか知りたいと思います。

誰かが私を助けたり、コードを共有したりできますか? アプリケーションを終了したら、私は自分のプロジェクトを共有したり、チュートリアルを作成する準備が整いました。

私のアプリケーションについての情報:私はバーコードをスキャンして、私のバーコードを保存したいapp 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 

答えて

3

もっとアニメーションを設定することはできません:はい。 ここにサンプルコードと権利コードがあります。

他人を助けることを願っています。

- (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]; 

} 

brush51

0

didFinishPickingMediaWithInfoでは、[self.tabBarController setSelectedIndex:1]に電話して2番目のタブに切り替える必要があります。

+0

あなたの答えをありがとうございました。 imagePickerController:didFinishPickingMediaWithInfoの後にXIBファイルを表示する方法を教えてください。私の目的は、別のXIBファイルをロードし、このロードされたXIBファイルにキャプチャされた画像とコード化されたコードを表示することです – brush51

関連する問題