2013-05-15 64 views
0

我正在使用RNBlurModalView(https://github.com/rnystrom/RNBlurModalView)模糊我的模态视图的背景。问题是,当我滚动我的表格视图时,屏幕截图也不会滚动。滚动时,模糊最终消失。我知道我需要使用内容表视图的偏移,但我不知道如何实现它在现有的代码ios tableview +屏幕截图

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

任何想法的代码?

谢谢。

+0

你能提供代码,你介绍模糊视图?我认为问题在于你将它添加到UITableView,所以它作为标题。 – Emanuel

+0

编辑了该问题以向您提供该代码 – jacobt

回答

0

好吧,因为我认为这个问题是,当你调用[[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是OK的时候,你只需要一个简单的表,但它不工作,当你想添加其他的意见好,所以试试这个:

修改您的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作为子视图。