gpt4 book ai didi

iphone - didSelectRowAtIndexPath 抛出异常

转载 作者:行者123 更新时间:2023-11-28 20:43:09 25 4
gpt4 key购买 nike

这可能是一些简单的错误,我似乎无法在我的代码中找到它。

每当我在我的表格 View 中点击一个单元格时,我都会得到一个异常

这是我的界面:

@interface MenuViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>

@end

我不使用 XIB 文件,所以这是我的 loadView

- (void)loadView
{
UIView *myview = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.title = @"Menu";
UITableView *tableViewMenuItems = [[UITableView alloc] initWithFrame:CGRectMake(10, 10, 300, 150) style:UITableViewStyleGrouped];
tableViewMenuItems.backgroundColor = [UIColor clearColor];
tableViewMenuItems.delegate = self;
tableViewMenuItems.dataSource = self;
tableViewMenuItems.scrollEnabled = NO;
[myview addSubview:tableViewMenuItems];
[tableViewMenuItems release];
self.view = myview;
[myview release];
}

这是选择行的委托(delegate)方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SendMessageViewController *sendMessageViewController = [[SendMessageViewController alloc] init];
[self.navigationController pushViewController:sendMessageViewController animated:YES];
[sendMessageViewController release];
}

还有我的BT

#0  0x94e3c9c6 in __pthread_kill ()
#1 0x98079f78 in pthread_kill ()
#2 0x9806abdd in abort ()
#3 0x9588a921 in abort_message ()
#4 0x958881bc in default_terminate ()
#5 0x010ee23b in _objc_terminate ()
#6 0x958881fe in safe_handler_caller ()
#7 0x95888268 in std::terminate ()
#8 0x958892a0 in __cxa_throw ()
#9 0x010ee416 in objc_exception_throw ()
#10 0x00f9c0bb in -[NSObject(NSObject) doesNotRecognizeSelector:] ()
#11 0x00f0b966 in ___forwarding___ ()
#12 0x00f0b522 in __forwarding_prep_0___ ()
#13 0x0008c870 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] ()
#14 0x00082b05 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:] ()
#15 0x0079c79e in __NSFireDelayedPerform ()
#16 0x00f7b8c3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#17 0x00f7ce74 in __CFRunLoopDoTimer ()
#18 0x00ed92c9 in __CFRunLoopRun ()
#19 0x00ed8840 in CFRunLoopRunSpecific ()
#20 0x00ed8761 in CFRunLoopRunInMode ()
#21 0x011d21c4 in GSEventRunModal ()
#22 0x011d2289 in GSEventRun ()
#23 0x00023c93 in UIApplicationMain ()
#24 0x00002589 in main (argc=1, argv=0xbffff698) at main.m:14

我做错了什么?

最佳答案

看看这一行

-[NSObject(NSObject) doesNotRecognizeSelector:] ()

它清楚地表明,当您单击表格 View 单元格时,您正在调用代码中某处不存在的方法。尝试在 SendMessageViewController

的 viewDidLoad 和 viewWill/DidAppear 方法中搜索警告

关于iphone - didSelectRowAtIndexPath 抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7552106/

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