我正在使用RNBlurModalView (https://github.com/rnystrom/RNBlurModalView)模糊我的模式视图的背景。问题是,当我滚动我的表视图时,屏幕截图也不会滚动。当您滚动时,模糊最终会消失。我知道我需要使用表视图的内容偏移,但不确定如何在现有代码中实现它
RNBlurModalView.m
#pragma mark - UIView + Screenshot
@implementation UIView (Screenshot)
- (UIImage*)screenshot {
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// hack, helps w/ our colors when blurring
NSData *imageData = UIImageJPEGRepresentation(image, 1); // convert to jpeg
image = [UIImage imageWithData:imageData];
return image;
}
@end和我的实现视图的代码
- (IBAction)locationPressed:(id)sender {
UIStoryboard *storyBoard = [self storyboard];
HomeViewController *homeView = [storyBoard instantiateViewControllerWithIdentifier:@"HomeViewController"];
RNBlurModalView *modal = [[RNBlurModalView alloc] initWithViewController:self title:@"Hello world!" message:@"Pur your message here."];
[modal show];
[self presentPopupViewController:homeView animationType:MJPopupViewAnimationSlideBottomBottom];有什么想法吗?
谢谢。
发布于 2013-05-16 12:13:56
好的,正如我所想的,问题是当你调用[[RNBlurModalView alloc] initWithViewController:self title:@"Hello world!" message:@"Pur your message here."];时,方法会将自己添加到给定控制器的视图中:
- (id)initWithViewController:(UIViewController*)viewController view:(UIView*)view {
if (self = [self initWithFrame:CGRectMake(0, 0, viewController.view.width, viewController.view.height)]) {
[self addSubview:view];
...
}因此,另一个问题是,当您只有一个简单的表时,使用UITableViewController是可以的,但是当您想要添加其他视图时,它就不能很好地工作了,所以尝试这样做:
修改您的viewDidLoad,使其如下所示:
- (void)viewDidLoad
{
[super viewDidLoad];
// create a new view to lay underneath the UITableView
UIView *view = [[UIView alloc] initWithFrame:self.view.frame];
view.autoresizingMask = self.view.autoresizingMask;
// add the uiTableView as a subview
[view addSubview:self.tableView];
self.view = view;
self.tableView.frame = view.bounds;
}它正在创建一个UIView并将其放在UITableView之下。
下一次您需要的不仅仅是常规的UITableView时,可以考虑使用UIViewController,并使用UITableView作为子视图。
https://stackoverflow.com/questions/16576251
复制相似问题