如何使用PFQueryViewController作为UITableViewController的子视图? [英] How can I use PFQueryViewController as a subview of UITableViewController?

查看:85
本文介绍了如何使用PFQueryViewController作为UITableViewController的子视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Parse构建群组消息传递应用程序.我只想使用情节提要是因为我是iOS的新手.

I’m trying to build a group messaging app with Parse. I would like to use storyboards only because I am new to iOS.

  • 第一个屏幕是带有组列表的UITableViewController.
  • 第二个屏幕是PFQueryTableViewController,它继承自UITableViewController并带有该组的消息列表.

我想在PFQueryViewController中添加一个聊天框(UITextField),但由于它是一个UITableViewController,我似乎无法做到这一点.

I would like to add a chat box(UITextField) to the PFQueryViewController, but I can’t seem to do that because it is a UITableViewController.

据我所知,为了添加聊天框,我需要使用UIViewController并手动添加表视图.然后调整表格视图的大小,以允许在底部有一个聊天框.

From what I can tell in order to add a chat box I need to use a UIViewController and manually add a table view. Then resize the table view to allow for a chat box at the bottom.

问题是,PFQueryViewController继承自UITableViewController而不是UITableView.

The problem is then PFQueryViewController inherits from a UITableViewController and not a UITableView.

我正在使用它将选定的组PFObject传递给新的PFQueryViewController.

I am using this to pass the selected group PFObject to the new PFQueryViewController.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    [self performSegueWithIdentifier:@"detail" sender:nil];

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    if([[segue identifier] isEqualToString:@"detail"])
    {
        NSIndexPath *ip = [self.tableView indexPathForSelectedRow];
        PFObject *passObj = [self.objects objectAtIndex:ip.row];
        PFQueryTableViewController *messageDetail=[segue destinationViewController];
        [messageDetail setReceiveObj:passObj];
        messageDetail.hidesBottomBarWhenPushed = YES; //Hide Tab Bar
    }

如何使用PFQueryViewController作为UIViewController的子视图并将PFObject传递给该控制器?

How can I use PFQueryViewController as a subview of UIViewController and pass the PFObject to that controller?

*我对图像的信誉不足

*I don't have enough reputation for images

推荐答案

我不熟悉Parse框架,但是您应该能够使用View Controller Containment实现此目的.

I'm, unfamiliar with the Parse framework but you should be able to use View Controller Containment to achieve this.

这里是结账的不错指南.

以下是将视图控制器的视图添加为另一个视图控制器中的子视图的相关部分:

Here is the relevant part for adding the view of a view controller as a subview in another view controller:

// put this in viewDidLoad
[self addChildViewController:_pfQueryController];               //  1
[self.view addSubview:_pfQueryController.view];                 //  2
[_pfQueryController didMoveToParentViewController:self];        //  3

这篇关于如何使用PFQueryViewController作为UITableViewController的子视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆