gpt4 book ai didi

iphone - 我必须延长哪一个类?

转载 作者:行者123 更新时间:2023-11-29 04:36:25 26 4
gpt4 key购买 nike

(我正在开发一个在表格中显示聊天消息的应用程序。但是,用户无法启动此聊天,当用户收到消息时,聊天 View 将打开。因此,我编写了以下代码:

- (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'

我认为解决第一个异常可以解决我的问题。有什么帮助吗?

谢谢。

最佳答案

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:];

希望这对您有帮助

关于iphone - 我必须延长哪一个类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11014622/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com