[英]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的新手。
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.