有一个基本形式,按下按钮调用方法performSegueWithIdentifier
,显示弹出窗口。在弹出框处于活动状态之前,如何使主视图窗口变黑(变暗)?
我尝试像这样使用库SVProgressHUD :
- (IBAction)publishButtonAction:(id)sender {
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];
[self performSegueWithIdentifier:@"fbshareSigue" sender:self];
[SVProgressHUD dismiss];
}
获得一瞬间 - 直到有一个弹出窗口。
如果我尝试这个,我必须在哪里插入这个代码?:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"fbshareSigue"]) {
OFAFBShareViewController *svc = (OFAFBShareViewController *) [segue destinationViewController];
UIStoryboardPopoverSegue *popoverSegue = (UIStoryboardPopoverSegue *)segue;
svc.postBlock = self.postInitBlock;
[svc setClosePopWindow:[popoverSegue popoverController]];
}
}
- (IBAction)publishButtonAction:(id)sender {
UIView *dimView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
dimView.backgroundColor = [UIColor blackColor];
dimView.alpha = 0.5f;
dimView.tag = 1111;
dimView.userInteractionEnabled = NO;
[self.view addSubview:dimView];
[self performSegueWithIdentifier:@"fbshareSigue" sender:self];
}
/* This code should be put in the other method where you are removing the popup.. Because it will remove the dim view. here is the wrong place for this code*/
/* for (UIView *view in [self.view subviews]) {
if (view.tag == 1111) {
[view removeFromSuperview];
}
}*/
昏暗的不行...
=====================
我有 ViewOFAResultViewController
调用 Popover ( OFAFBShareViewController
):
...
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"fbshareSigue"]) {
OFAFBShareViewController *svc = (OFAFBShareViewController *) [segue destinationViewController];
UIStoryboardPopoverSegue *popoverSegue = (UIStoryboardPopoverSegue *)segue;
svc.postBlock = self.postInitBlock;
[svc setClosePopWindow:[popoverSegue popoverController]];
}
}
- (IBAction)publishButtonAction:(id)sender {
UIView *dimView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
dimView.backgroundColor = [UIColor blackColor];
dimView.alpha = 0.5f;
dimView.tag = 1111;
dimView.userInteractionEnabled = NO;
[self.view addSubview:dimView];
[self performSegueWithIdentifier:@"fbshareSigue" sender:self];
}
...
在OFAFBShareViewController
我试图关闭昏暗的视图:
...
- (IBAction)cancelButtonAction:(id)sender {
[closePopWindow dismissPopoverAnimated:YES];
for (UIView *view in [self.view subviews]) {
if (view.tag == 1111) {
[view removeFromSuperview];
}
}
...
但是又不行了……