0

彼らの猫についてのランダムなキャプションを与えるアプリを作るように頼まれました。2 つの問題があり、チュートリアルを段階的に実行しましたが、何も機能しませんでした。1.写真を撮ったり選択したりするたびに、UIImageViewに表示されず、すべてがストーリーボードに表示されますが、わかりません。また、ランダムなキャプションを作成し、ボタンを押すと正常に動作する IBAction を作成しましたが、写真を撮影または選択したときにキャプションが自動的に表示される場所はありますか? これが.Mファイルの私のコードです。アプリ作成に関しては初心者です。

#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です

4

1 に答える 1

0

画像は自動リリースされます。範囲外になる前に imageView を設定するか、保持してください。何かに接続している場合は、メモリに保持されて表示されるはずです。

于 2013-03-28T22:02:32.570 に答える