Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iphone sdk中使用DEFacebookComposeViewController时出现白色背景问题_Iphone - Fatal编程技术网

在iphone sdk中使用DEFacebookComposeViewController时出现白色背景问题

在iphone sdk中使用DEFacebookComposeViewController时出现白色背景问题,iphone,Iphone,我正在使用DEFacebookComposeViewController在Facebook上共享 我在一个视图控制器中遇到问题,它将视图的背景颜色更改为白色,而不是透明的黑色背景。我设法解决了这个问题。您需要取消注释以下文件中的代码: “损坏BookComposeViewController.h” 只需替换以下代码: (无效)视图将显示:(BOOL)动画 { [超级视图将显示:动画] // Take a snapshot of the current view, and make that o

我正在使用DEFacebookComposeViewController在Facebook上共享


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

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

只需替换以下代码:

  • (无效)视图将显示:(BOOL)动画 { [超级视图将显示:动画]

    // 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];

   }
希望这将有助于其他人,如果他们发现类似的问题


谢谢。

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

self.modalPresentationStyle = UIModalPresentationCurrentContext;


您的工作将完成。

请注意,只有当我在添加的子视图上按viewController时,才会发生这种情况。它工作正常。这为我解决了问题。我希望我首先了解导致它的原因。事实上,该行是错误的。它是针对viewController内部代码的。而不是外部实现。
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;