0

ユーザーがUITableViewControllerで行を選択したときに、別のviewControllerにセグエし、そのUIImageViewを以前に設定された画像に設定したいと思います。今のところ、私はそれを一般的にしています-常に/images/en.jpegを表示します。

flickrTVC.m(UITableViewController):

@implementation flickrTVC

...

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"showPhoto"])
        UIImage *photo = [UIImage imageWithContentsOfFile:@"images/en.jpeg"];
        [segue.destinationViewController setDisplayedPhoto:photo];
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"showPhoto" sender:self];
}

-(void)setDisplayedPhoto:( UIImage *)image; (self.photoをimageに設定します)私のphotoViewController.h(segue.destinationViewController)で。私は得ています

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setDisplayedPhoto:]: unrecognized selector sent to instance 0x1f5c4a60'

次の行:[segue.destinationViewController setDisplayedPhoto:photo]; 。実装が空白の場合でも、エラーは表示されます。私はobjective-cを初めて使用しますが、おそらく、いくつかのことを台無しにしているだけです。

どんな助けでもいただければ幸いです。ありがとう!

4

1 に答える 1

1

そこにあったオブジェクトがメソッドを定義していないため、例外が発生しますsetDisplayedPhoto:。これは、segue.destinationViewControllerが現在完全に異なるコントローラーに設定されていることが原因である可能性があります(たとえば、考えているものとは異なるビューの場合)。また、そのメソッドに似ているが、まったく同じではないものを定義した可能性もあります。その場合、コンパイラはおそらくsetDisplayedPhoto:メソッド呼び出しに関する警告を発行しています。

于 2012-07-17T02:45:36.177 に答える