我必须扩展哪个课程?
问题描述:
(我正在开发一个应用程序,用于在表格中显示聊天消息,但是,当用户收到聊天视图打开的消息时,用户无法启动该聊天,因此我创建了以下代码:我必须扩展哪个课程?
- (void) newMessageReceived:(NSMutableDictionary *)message
{
General *general = [General sharedManager];
NSString *firstmessage=[message objectForKey:@"msg"];
NSString *from=[message objectForKey:@"sender"];
NSArray *listItems = [from componentsSeparatedByString:@"@"];
NSString *fromsplit=[listItems objectAtIndex:0];
general.firstmess=firstmessage;
general.firstfrom=fromsplit;
NSLog(@"Mensaje recibido: %@ de %@", [message objectForKey:@"msg"], fromsplit);
ChatViewController *cvc=[[ChatViewController alloc]initWithNibName:@"Chat" bundle:nil];
[[self navigationController]pushViewController:cvc animated:YES];
}
一切正常,直到这里的ChatViewController延伸的UITableViewController但是,当收到一个消息,我得到以下异常:。
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "Chat" nib but didn't get a UITableView.
然后,我试图改变延伸到的UIViewController类(这样做检查程序是否输入numberOfRowsInSection方法),然后我收到:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ChatViewController setTableViewStyle:]: unrecognized selector sent to instance 0x9863200'
我认为解决第一个异常会解决我的问题。任何帮助?
谢谢。
答
解决了它。我点击.xib文件,在“对象”下,点击“查看”。然后,在Identity Inspector(第三个,从左边开始)中,在Custom Class中,将其设置为UITableView。这只是“查看”之前。然后,一切正常。
答
In the second exception i think you have called [self setTableViewStyle:] method, while
you have made it UIViewController.
So try to call this method by tableViewOutlet.
[tableView setTableViewStyle:];
希望这将帮助你
+0
Abhishek,这个方法在我的代码中没有被我调用,是一个叫它的框架。但是,无论如何,我解决了它,你可以阅读下面。谢谢! :) – Fustigador
什么是 “Chat.xib” 是什么样子?它必须包含一个表格视图。 – jrturton
它有一个TableView,链接到他的Controller中的Outlet。 – Fustigador