我有一个我编写的代码,当按下按钮时会调用UIScrollView。问题是即使按下另一个按钮,它仍然在屏幕上。我无法弄清楚如何结束或解雇这个。
(IBAction)onClickSize:(id)sender {
viewSizePrint.hidden = YES; scrlView.contentSize = CGSizeMake(1500, 214); for (int i=0; i<20; i++) { UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(158*i+22, 2, 154, 210)]; imgView.tag = i+10; [scrlView addSubview:imgView]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; [btn setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"layout%d_thumbnail", i+1]] forState:UIControlStateNormal]; btn.frame = CGRectMake(158*i+30, 10, 138, 194); btn.tag = i; [btn addTarget:self action:@selector(onClickTheme:) forControlEvents:UIControlEventTouchUpInside]; [scrlView addSubview:btn]; } [self refreshTheme:[AppDelegate sharedAppDelegate].shrTheme]; }
答案 0 :(得分:0)
[scrlView removeFromSuperview];
scrlView = nil;