首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ios tableview +截图

ios tableview +截图
EN

Stack Overflow用户
提问于 2013-05-16 06:48:10
回答 1查看 266关注 0票数 0

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

代码语言:javascript
运行
复制
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

和我的实现视图的代码

代码语言:javascript
运行
复制
- (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];

有什么想法吗?

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-16 12:13:56

好的,正如我所想的,问题是当你调用[[RNBlurModalView alloc] initWithViewController:self title:@"Hello world!" message:@"Pur your message here."];时,方法会将自己添加到给定控制器的视图中:

代码语言:javascript
运行
复制
- (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,使其如下所示:

代码语言:javascript
运行
复制
- (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作为子视图。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16576251

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档