1

我正在使用 DEFacebookComposeViewController 在 Facebook 上共享。

我在一个视图控制器中遇到问题,它将视图的背景颜色更改为白色而不是透明的黑色背景。白色背景问题

4

2 回答 2

3

无需在代码中的任何地方进行更改,只需在实现模块中替换此代码即可

self.modalPresentationStyle = UIModalPresentationCurrentContext;

appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;

你的工作将完成。

于 2013-02-18T09:03:31.610 回答
0

我设法解决了这个问题。您需要取消注释以下文件中的代码:“DEFacebookComposeViewController.h”

只需替换以下代码:

  • (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated];

    // Take a snapshot of the current view, and make that our background after our view animates into place.
    // This only works if our orientation is the same as the presenting view.
    // If they don't match, just display the gray background.
      if (self.interfaceOrientation == self.fromViewController.interfaceOrientation) {
    //        UIImage *backgroundImage = [self captureScreen];
    //        self.backgroundImageView = [[[UIImageView alloc]               initWithImage:backgroundImage] autorelease];
       }
       else {
       //            self.backgroundImageView = [[[UIImageView alloc] initWithFrame:self.fromViewController.view.bounds] autorelease];
    }
          //    self.backgroundImageView.autoresizingMask = UIViewAutoresizingNone;
    //    self.backgroundImageView.alpha = 0.0f;
    //    self.backgroundImageView.backgroundColor = [UIColor lightGrayColor];
    //    [self.view insertSubview:self.backgroundImageView atIndex:0];
    
    // Now let's fade in a gradient view over the presenting view.
       self.gradientView = [[[DEFacebookGradientView alloc] initWithFrame:[UIApplication sharedApplication].keyWindow.bounds] autorelease];
       self.gradientView.autoresizingMask = UIViewAutoresizingNone;
       self.gradientView.transform = self.fromViewController.view.transform;
       self.gradientView.alpha = 0.0f;
       self.gradientView.center = [UIApplication sharedApplication].keyWindow.center;
       [self.fromViewController.view addSubview:self.gradientView];
       [UIView animateWithDuration:0.3f
                 animations:^ {
                     self.gradientView.alpha = 1.0f;
                 }];    
    
       self.previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
       [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:YES]; 
    
       [self updateFramesForOrientation:self.interfaceOrientation];
    
          }
    

使用此代码:

   - (void)viewWillAppear:(BOOL)animated
   {
       [super viewWillAppear:animated];

    // Take a snapshot of the current view, and make that our background after our view animates into place.
    // This only works if our orientation is the same as the presenting view.
    // If they don't match, just display the gray background.
if (self.interfaceOrientation == self.fromViewController.interfaceOrientation) {
    UIImage *backgroundImage = [self captureScreen];
    self.backgroundImageView = [[[UIImageView alloc] initWithImage:backgroundImage] autorelease];
}
else {
    self.backgroundImageView = [[[UIImageView alloc] initWithFrame:self.fromViewController.view.bounds] autorelease];
}
self.backgroundImageView.autoresizingMask = UIViewAutoresizingNone;
self.backgroundImageView.alpha = 0.0f;
self.backgroundImageView.backgroundColor = [UIColor lightGrayColor];
[self.view insertSubview:self.backgroundImageView atIndex:0];

    // Now let's fade in a gradient view over the presenting view.
self.gradientView = [[[DEFacebookGradientView alloc] initWithFrame:[UIApplication sharedApplication].keyWindow.bounds] autorelease];
self.gradientView.autoresizingMask = UIViewAutoresizingNone;
self.gradientView.transform = self.fromViewController.view.transform;
self.gradientView.alpha = 0.0f;
self.gradientView.center = [UIApplication sharedApplication].keyWindow.center;
[self.fromViewController.view addSubview:self.gradientView];
[UIView animateWithDuration:0.3f
                 animations:^ {
                     self.gradientView.alpha = 1.0f;
                 }];    

self.previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:YES]; 

[self updateFramesForOrientation:self.interfaceOrientation];

   }

如果他们发现类似的问题,希望这对其他人有帮助。

谢谢。

于 2012-10-10T17:11:01.080 回答