(我正在开发一个在桌面上显示聊天消息的应用程序。但是,当用户收到聊天视图打开的消息时,用户无法启动此聊天。所以,我制作了以下代码:
- (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'
我认为解决第一个例外会解决我的问题。有什么帮助吗?
谢谢。
答案 0 :(得分:1)
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:];
希望这会对你有所帮助
答案 1 :(得分:0)
解决了它。我单击.xib文件,在“对象”下,单击“查看”。然后,在Identity Inspector(第三个,从左侧开始)中,在Custom Class中,将其设置为UITableView。它之前简直就是“查看”。然后,一切正常。