我正在努力获得赛格右,但我没有得到它。我在游戏编程方面有经验,但是在客观上是初学者。我试图在应用中拍照,然后将其显示到另一个视图控制器上,以便用户可以裁剪它。
这是我Viewcontroller.h塞格dosent工作在所有
#import <UIKit/UIKit.h>
#import "CropViewController.h"
@interface ViewController : UIViewController <UIImagePickerControllerDelegate,
UINavigationControllerDelegate> {
UIImagePickerController *picker;
UIImage *image;
IBOutlet UIImageView *imageview;
CropViewController *cropVC;
}
- (IBAction)TakePhoto;
我Viewcontroller.m是
#import "ViewController.h"
#import "CropViewController.h"
@interface ViewController()
@end
@implementation ViewController
-(IBAction)TakePhoto {
picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker animated:YES completion:nil];
[self performSegueWithIdentifier:@"CropImage" sender:self];
}
- (void)imagePickerControllerDidCancel :(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"CropImage"])
{
CropViewController *CropViewController = segue.destinationViewController;
CropViewController.theImage = picker;
// Similar to [segue.destinationViewController setTheImage:yourImage];
}
}
-(void)createDirectory:(NSString *)ShoesDirectory atFilePath:(NSString *)filePath
{
NSString *filePathAndDirectory = [filePath stringByAppendingPathComponent:ShoesDirectory];
NSError *error;
if (![[NSFileManager defaultManager] createDirectoryAtPath:filePathAndDirectory
withIntermediateDirectories:NO
attributes:nil
error:&error])
{
NSLog(@"Create directory error: %@", error);
}
}
我CropViewController是
@interface CropViewController : UITableViewController
@property (nonatomic, retain) UIImage *theImage;
@property UIImage *picker;
我希望用户按下相机按钮,在视图控制器,然后拍照,然后将图片显示到CopViewController所在的位置和UImageView。如果我使用上面的代码,它会生成,但是当我按下“相机”按钮时,应用程序会停止。
更新这里是我没碰应用Delagate
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
2013年7月19日14坠毁:11:25.226 [4758:907] *终止应用程序由于未捕获的 异常 'NSInvalidArgumentException' ,原因: '接收器 ()具有标识符 没有赛格瑞 'CropImage'' *第一掷调用堆栈:(0x343192a3 0x3bffd97f 0x3632ce31 0x891ef 0x3620c0c5 0x3620c077 0x3620c055 0x3620b90b 0x3620be01 0x361345f1 0x36121801 0x3612111b 0x37e285a3 0x37e281d3 0x342ee173 0x342ee117 0x342ecf99 0x3425febd 0x3425fd49 0x37e272eb 0x36175301 0x88eed 0x3c434b20)的libC++ abi.dylib:终止叫做抛出异常 (LLDB)
你可以发布堆栈跟踪或控制台中的错误崩溃? –
我更新了我的帖子 – user2590480
我认为一些答案是部分正确的。您不需要同时推送选取器视图控制器*和*执行一个segue。你想要做一个或另一个。崩溃的错误表明它不知道segue“CropImage”。所以你的视图控制器不能有这个名字。 –