2012-03-28 58 views
1

iPhone - 5.1(9B176)的iOS重疊視圖 - 一個視圖掩蔽的UITableViewController被部分地遮蔽的UITableViewController

我在覆蓋上一個UITableViewController的頂部上的掩模圖中所示的畫面被下面遇到不一致的行爲。任何人遇到這種行爲,如果是的話,請提出任何解決方案?

Partially masked view on top of UITableViewController

下面是我用來添加面具視圖代碼:

//Add the overlay view. 
if(ovController == nil) { 
    NSString *cellIdentifier = @"overlayVC"; 
    ovController = [[self storyboard] instantiateViewControllerWithIdentifier:cellIdentifier]; 
} 

CGFloat yaxis = self.navigationController.navigationBar.frame.size.height; 
CGFloat width = self.view.frame.size.width; 
CGFloat height = self.view.frame.size.height; 

CGRect frame = CGRectMake(0, yaxis, width, height); 
ovController.view.frame = frame; 
ovController.view.alpha = 0.85; 
ovController.delegate = self; 

UIView *aboveView = self.parentViewController.view; 

[self.tableView insertSubview:ovController.view aboveSubview:aboveView]; 

我也曾嘗試

`[self.tableView insertSubview:ovController.view aboveSubview:self.tableView]` 

回答

4

嗨使用類似下面的代碼

-(void) showLoadingView { 

//NSLog(@">>>>>>>>>>>>>>>>> loading view Landscape right "); 
if (loadView == nil) { 
    loadView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)]; 
    loadView.opaque = NO; 
    loadView.backgroundColor = [UIColor clearColor]; 
    //loadView.alpha = 0.8; 

    viewBack = [[UIView alloc] initWithFrame:CGRectMake(95, 230, 130, 40)]; 
    viewBack.backgroundColor = [UIColor blackColor]; 
    viewBack.alpha = 0.7f; 
    viewBack.layer.masksToBounds = NO; 
    viewBack.layer.cornerRadius = 8; 

    spinningWheel = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(5.0, 5.0, 30.0, 30.0)]; 
    [spinningWheel startAnimating]; 
    //  spinningWheel.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; 
    [viewBack addSubview:spinningWheel]; 
    [spinningWheel release];   

    UILabel *lblLoading = [[UILabel alloc] initWithFrame:CGRectMake(23, 6, 110, 25)]; 
    lblLoading.backgroundColor = [UIColor clearColor]; 
    lblLoading.font = [UIFont fontWithName:@"Helvetica-Bold" size:16.0]; 
    lblLoading.textAlignment = UITextAlignmentCenter; 
    lblLoading.textColor = [UIColor whiteColor]; 
    lblLoading.text = @"Loading..."; 
    [viewBack addSubview:lblLoading]; 
    [loadView addSubview:viewBack]; 
}  

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    loadView.frame = iphoneFrame; 
    viewBack.frame = loadiPhone;   
} 
else 
{ 
    loadView.frame = ipadFrame; 
    viewBack.frame = loadiPad; 
} 

[self.window addSubview:loadView]; 

}

- (無效){hideLoadingView

[loadView removeFromSuperview]; 

}

聲明此方法在你的AppDelegate類,所以你可以從你的代碼中的任何視圖調用它。

在這裏,我已經設置在窗戶上沒有考慮到這surelu解決您的問題的視圖!!!!

+0

謝謝尼爾。您的解決方案的一部分工作但我還需要一個帶有其他目的的蒙面視圖。將子視圖添加到窗口工作。 [[的appDelegate窗口] addSubview:ovController.view]; 但是我仍然想知道爲什麼在UITableViewController插入一個子視圖頂部的表視圖不能按預期工作。 – 2012-03-28 11:46:46

+0

不知道確切的原因,但你可以通過在viewcontroller中插入表和加載視圖來做到這一點...我想你有我的觀點 – 2012-03-28 12:03:13