0
我被要求製作一個應用程序,提供關於他們的貓的隨機標題。我有兩個問題,我一步一步跟着教程,沒有任何工作。 1.當拍攝或選擇一張照片時,它不會顯示在UIImageView中,故事板中的每一個東西都會被喜歡,我只是不明白。另外,我在製作隨機標題的地方製作了一個IBAction,當它按下按鈕時,它可以正常工作,無論如何,當圖片被拍攝或選擇時,標題會自動顯示在哪裏?這是我的.M文件中的代碼。當談到製作應用程序時,我是一名初學者。iPhone標題攝像頭,imageview不顯示拍攝的照片
#import "Generator.h"
@interface Generator()
@end
@implementation Generator
-(IBAction)TakePhoto{
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker animated:YES completion:NULL];
}
-(IBAction)ChooseExisting{
picker2 = [[UIImagePickerController alloc] init];
picker2.delegate = self;
[picker2 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:picker2 animated:YES completion:NULL];
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[self dismissViewControllerAnimated:YES completion:NULL];
}
-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:NULL];
}
-(IBAction)Back{
[self dismissViewControllerAnimated:YES completion:NULL];
}
-(IBAction)random {
int text = rand() % 10;
switch (text) {
case 0:
textview.text = @"I'd Say About Average";
break;
case 1:
textview.text = @"Happy but Hideous";
break;
case 2:
textview.text = @"Furrific";
break;
case 3:
textview.text = @"Cuddly";
break;
case 4:
textview.text = @"Abby Normal";
break;
case 5:
textview.text = @"Purrty";
break;
case 6:
textview.text = @"Yuck";
break;
case 7:
textview.text = @"Glowing";
break;
case 8:
textview.text = @"AWWWWWW";
break;
case 9:
textview.text = @"The Cutest";
break;
default:
break;
}
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
任何幫助都會做。我的SDK是iOS 6.1
您上面的代碼沒有imageView。 你想在這裏做什麼? image = [info objectForKey:UIImagePickerControllerOriginalImage]; – 2013-03-14 22:05:24
「image = [info objectForKey:UIImagePickerControllerOriginalImage];」什麼是形象?它應該是'urImageView.image = ...' – 7usam 2013-03-14 22:05:55
什麼是meathod設置拍攝到imageview我有嗎? – goofballcent 2013-03-15 01:03:48