我正在尝试为餐厅制作一个应用程序,并将食物菜单显示为可滚动的图像。图像是从配置文件中提取的。
- (void)viewDidLoad
{
[super viewDidLoad];
// back button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"btn-back.png"] forState:UIControlStateNormal];
button.frame = CGRectMake(0.0f, 0.0f, 46.0f, 28.0f);
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
[customBarItem release];
[self setTitle:[menu objectForKey:@"title"]];
[scrollView2 setScrollEnabled:YES];
NSString *imageName = [menu objectForKey:@"imageName"];
if (![imageName isEqualToString:@""]) {
UIImage *image = [UIImage imageNamed:imageName];
[imageView setImage:image];
[scrollView2 addSubview:imageView];
[imageView release];
}
[textView setText:[menu objectForKey:@"description"]];
}
截至目前,图像不会滚动,而是显示为静态图像。任何人都可以帮我修改此代码,以便用户可以垂直滚动图像。非常感谢。