グループ化されたUITableViewの背後にビューを追加しようとしています。残念ながら、私がスクロールするたびに、バックグラウンドビューも動きます。これは[self.view insertSubview:backgroundView belowSubview:_tableView]、または[_tableView setBackgroundView:backgroundView]を使用しても発生します。この背景ビューがスクロールする理由は何ですか?また、私はなぜスクロールを無効にしても、私のtableViewスクロールはしますか?これらは関連していますか? history.mでUITableViewで固定の背景ビューを作成するには?
History *historyController = [[History alloc] init];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:historyController];
:アプリのデリゲートで
あなたのコントローラがUITableViewController
だけtableView
でUIViewController<UITableViewDelegate, UITableViewDatasource>
に変更している場合
- (void)viewDidLoad {
CGRect frame = self.view.frame;
frame.origin.x = 0;
frame.origin.y = 0;
_tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
[_tableView setScrollEnabled:NO];
[_tableView setBackgroundColor:[UIColor clearColor]];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
UIView *bg = [[UIView alloc] initWithFrame:frame];
[bg setBackgroundColor:[UIColor scrollViewTexturedBackgroundColor]];
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CenterFade.png"]];
iv.alpha = .750;
[bg addSubview:iv];
[iv release]; iv = nil;
[self.view addSubview:bg];
[self.view addSubview:_tableView];
[bg release]; bg = nil;
[_tableView release];
[super viewDidLoad];
}
私はシミュレータからアプリケーションを削除してしまいました。そして、私が再び走ったとき、この問題はなくなりました。繰り返しクリーニングや再構築にもかかわらず、何かが更新されていないようなバグだったようです。 (私はUITableViewControllerからUIViewControllerに変更しました)。 – arsenius