我正在使用DEFshootingComposeViewController在Facebook上分享。在iphone中使用DEFshootingComposeViewController的白色背景問題sdk
我在一個視圖控制器有問題,它將視圖的背景顏色更改爲白色而不是透明的黑色背景。
我正在使用DEFshootingComposeViewController在Facebook上分享。在iphone中使用DEFshootingComposeViewController的白色背景問題sdk
我在一個視圖控制器有問題,它將視圖的背景顏色更改爲白色而不是透明的黑色背景。
我設法解決了這個問題。您需要取消註釋下列文件中的代碼: 「DEFacebookComposeViewController.h」
只需更換下面的代碼:
(無效)viewWillAppear中:(BOOL)動畫 { [超級viewWillAppear中:動畫]。
// 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];
}
希望這將有助於其他,如果他們發現類似的問題。
謝謝。
無需更改代碼的任何地方,只要有
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
將這段代碼中實現模塊
self.modalPresentationStyle = UIModalPresentationCurrentContext;
和你的工作將b完成。
這解決了我的問題。我希望我首先了解是什麼引起了它。 –
其實這條線是錯的。 IT用於代碼內部的viewcontroller .. NOt用於外部實現。 –
請注意,這隻發生在我推視圖控制器添加子視圖時,它工作正常。 –