我已经在主 ViewController 中创建了一个表格视图,一旦我触摸到下一个视图控制器(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)
{
}];
}