我有一個UITableView,我正在應用一組過濾器。當我點擊「過濾器」按鈕時,導航欄下面的過濾器就會生成動畫。我在這裏做的是將一個NIB加載到UITableView的超級視圖中。 當我啓動視圖時,此功能完美。我能夠顯示並隱藏過濾器NIB。 但是,通過點擊主頁按鈕將應用程序發送到背景後,我再次啓動應用程序以將其帶入前臺。 現在我加載並附加到UITableView的超級視圖的NIB已經接管了屏幕。 tableview隱藏在這個視圖的下方,我可以通過隱藏過濾器NIB來看到一小段命中。 儘管我添加到超級視圖中的NIB具有75的高度,但當它進入前景時,我可以看到它的框架現在具有超過400的大小。 有沒有人有任何想法,爲什麼會發生這種情況超級觀點? 感謝iOS - UITableView的超級視圖覆蓋屏幕,當應用程序進入前景
我的代碼
- (IBAction)filterButtonPressed:(UIBarButtonItem *)sender
{
//If the filter view is displayed on screen then remove it.
if(self.filterViewDisplayed == YES){
[self animateFilterButtonsWithButtonsYOrigin:-75 tableViewYOrigin:-75];
self.filterViewDisplayed = NO;
}else {
//Determine if we should load the FilterButtons XIB
if(self.filterViewLoaded == NO) {
self.filterViewLoaded = YES;
[self.tableView.superview addSubview:self.activityFilter];
}
self.filterViewDisplayed = YES;
//Set the delegate of the ActivityFilter to self so that we can handle callbacks.
self.activityFilter.delegate = self;
//Set the intial frame of the filter buttons to be -75 pixels off the top of the screen
CGRect filterFrame = self.activityFilter.frame;
filterFrame.origin.y = -75;
self.activityFilter.frame = filterFrame;
//Now animate the filter buttons to appear at origin 0.
[self animateFilterButtonsWithButtonsYOrigin:0 tableViewYOrigin:75];
}
}
- (void)animateFilterButtonsWithButtonsYOrigin:(CGFloat)yOrigin tableViewYOrigin:(CGFloat)tableViewYOrigin
{
[UIView animateWithDuration:0.25
animations:^{
CGRect filterFrame = self.activityFilter.frame;
filterFrame.origin.y = yOrigin;
self.activityFilter.frame = filterFrame;
[self adjustTableViewOriginBy:tableViewYOrigin];
}];
}
-(void)adjustTableViewOriginBy:(CGFloat)yOrigin
{
CGRect tableFrame = self.tableView.frame;
tableFrame.origin.y += yOrigin;
self.tableView.frame = tableFrame;
}
截圖
- 過濾動畫前過濾器應用於
- 後,從後臺啓動後 - 這裏問題。上海華佔據了整個視圖
- 隱藏過濾器揭示了上海華