简体   繁体   English

如何使用PFQueryViewController作为UITableViewController的子视图?

[英]How can I use PFQueryViewController as a subview of UITableViewController?

I'm trying to build a group messaging app with Parse. 我正在尝试使用Parse构建群组消息传递应用程序。 I would like to use storyboards only because I am new to iOS. 我只想使用情节提要是因为我是iOS的新手。

  • The first screen is a UITableViewController with a list of groups. 第一个屏幕是带有组列表的UITableViewController。
  • The second screen is a PFQueryTableViewController that inherits from UITableViewController with a list of messages for that group. 第二个屏幕是PFQueryTableViewController,它继承自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. 我想在PFQueryViewController中添加一个聊天框(UITextField),但由于它是一个UITableViewController,所以似乎无法做到这一点。

From what I can tell in order to add a chat box I need to use a UIViewController and manually add a table view. 据我所知,为了添加聊天框,我需要使用UIViewController并手动添加表视图。 Then resize the table view to allow for a chat box at the bottom. 然后调整表格视图的大小,以允许在底部的聊天框。

The problem is then PFQueryViewController inherits from a UITableViewController and not a UITableView. 问题是,PFQueryViewController继承自UITableViewController而不是UITableView。

I am using this to pass the selected group PFObject to the new PFQueryViewController. 我正在使用它来将选定的组PFObject传递给新的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
    }

How can I use PFQueryViewController as a subview of UIViewController and pass the PFObject to that controller? 如何使用PFQueryViewController作为UIViewController的子视图并将PFObject传递给该控制器?

*I don't have enough reputation for images *我对图像的信誉不足

I'm, unfamiliar with the Parse framework but you should be able to use View Controller Containment to achieve this. 我对Parse框架不熟悉,但是您应该可以使用View Controller Containment实现此目的。

Here is a nice guide to check out. 这是一个不错的退房指南。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当UITableViewController的子类包含在子视图中时,它不会触发didSelectRowAtIndexPath,我该如何解决? - Subclass of UITableViewController will not fire didSelectRowAtIndexPath when it is contained in a subview, how can I fix this? 如何挂钩子视图的子视图? - How can I hook a subview of a subview? 如何在UITableViewController中引用自定义UIView的子视图按钮 - How to Refer to a Subview Button of Custom UIView in UITableViewController 如何使用IBInspectable控制子视图的属性? - How can I use IBInspectable to control a property of a subview? 如何将UITableView或UITableViewController集成到UIPageViewController中? - How can I integrate an UITableView or UITableViewController into a UIPageViewController? 如何在UITableViewController中分配异构数据源? - How can I assign heterogenous datasource in UITableViewController? 如何向 UITableViewController 添加粘性页脚? - How can I add a sticky footer to UITableViewController? 如何调整UITableViewController中的节和行? - How can I adjust the section and row in UITableViewController? 如何将子视图添加到另一个子视图并使其显示? - How can I add a subview to another subview and make it appear? 在子视图上添加UITableViewController - Adding An UITableViewController on to a SubView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM