0

メインのViewControllerでテーブルビューを作成しました。行をタッチすると、次のView Controller(DetailViewController)に移動し、画像と料理の名前が表示されます。画像をタップすると、大きくなるはずですが、そうではありません。以下のコードは、DetailViewControllerで試したものです。

DetailViewController.m

- (void)viewDidLoad
{
[super viewDidLoad];
imageView=[[UIImageView alloc] initWithFrame:CGRectMake(10, 10,100, 100)];
CGRect textViewFrame = CGRectMake(10, 10, 300, 400);
textView = [[UITextView alloc] initWithFrame:textViewFrame];
textView.returnKeyType = UIReturnKeyDone;
textView.backgroundColor=[UIColor whiteColor];
textView.editable=NO;
textView.delegate = self;
[self.view addSubview:textView]; 
[textView addSubview:imageView];
textView.alpha = 0.9;
textView.font = [UIFont systemFontOfSize:15];

if(mrowno==0)
{
     imageView.image=[UIImage imageNamed:@"Dosa.jpg"];  
    textView.text = @"\n\n\n\n\n\n\n\nDOSA\nDosa, ";
    imageButton = [[UIButton alloc]init];
    [imageButton setFrame:CGRectMake(0, 0, 100, 100)];
    [imageButton addTarget:self action:@selector(imageTapped:) forControlEvents:UIControlEventTouchUpInside];
    [imageView addSubview:imageButton];

}

画像を大きくする方法は次のとおりです

-(void)imageTapped:(UIButton*)in_sender
{


[UIView transitionWithView:in_sender.superview  duration:0.8f  options:UIViewAnimationOptionCurveLinear  animations:^
 {  
     [in_sender.superview setFrame:CGRectMake(0, 0, 300, 500)];
 }
                completion:^(BOOL finished) 
 {
 }];
}
4

2 に答える 2

0

使用したくないtransitionWithView。代わりに、+ animateWithDuration: delay:options:animations:completion:(またはその短いバリアントのいずれかを...)使用する必要があります

[UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
    viewYouWantToAnimate.frame = CGRectMake(..., ..., ..., ...);
} completion:^{
    //Add completion code here, or pass nil if you don't have anything to do.
}];

編集:transitionWithViewがどのように使用されているのか疑問に思っている場合は、AppleDocsには、remove / addSubviewメソッド(フレーム変更ではない)のアニメーションを追加する優れた例があります。

[UIView transitionWithView:containerView
       duration:0.2
       options:UIViewAnimationOptionTransitionFlipFromLeft
       animations:^{
           [fromView removeFromSuperview];
           [containerView addSubview:toView];
       } completion:NULL];
于 2013-03-04T06:09:31.983 に答える
0

必要に応じて、ピンチインおよびピンチアウトすることで画像のサイズを拡大および縮小できます

-(void)viewDidLoad
 { 
 UIPinchGestureRecognizer* pinch=[[UIPinchGestureRecognizer alloc] initWithTarget:self            action:@selector(pinching:)];
[self.imageView addGestureRecognizer:pinch];
  }

-(void)pinching:(UIGestureRecognizer*) recognizer
 {
UIPinchGestureRecognizer* pinch=(UIPinchGestureRecognizer*) recognizer;
self.imageView.transform=CGAffineTransformScale(self.imageView.transform, pinch.scale, pinch.scale);
pinch.scale=1;
NSLog(@"pinching");
 }
于 2013-03-04T06:41:29.573 に答える