sol*_*tan 12 iphone uitableview
我知道之前提到的这个问题,但那里的决议并不适用.我有一个UINavigationController,它使用IB设置嵌入式UITableViewController.在IB中,UITableView的委托和dataSource都设置为我的UITableViewController的派生.使用XCode的UITableViewController类模板添加了这个类.没有自定义UITableViewCell,表视图仅使用具有单个标题的默认普通样式.
好吧,在模拟器中,列表正确呈现,dataSource提供了两个元素,因此dataSource正确链接.如果我在IB中删除了dataSource的出口链接,则会呈现一个空表.
一旦我点击这两个项目中的一个,它就会闪烁蓝色并且GDB __forwarding__
在a的范围内遇到中断UITableView::_selectRowAtIndexPath
.它没有达到我的非空方法didSelectRowIndexPath中设置的断点.我检查了参数和方法的名称,以排除导致不同选择器的拼写错误.
我最近没有成功设置委托是否正确,但因为它被设置为等同于从同一个类中获取两个元素的dataSource,我希望它能够正确设置.那么,怎么了?
我正在运行iPhone/iPad SDK 3.1.2 ...但是在模拟器中尝试使用iPhone SDK 3.1.
编辑:这是我的UITableViewController派生的代码:
#import "LocalBrowserListController.h"
#import "InstrumentDescriptor.h"
@implementation LocalBrowserListController
- (void)viewDidLoad {
[super viewDidLoad];
[self listLocalInstruments];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
[super viewDidUnload];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [entries count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if ( ( [entries count] > 0 ) && ( [indexPath length] > 0 ) )
cell.textLabel.text = [[[entries objectAtIndex:[indexPath indexAtPosition:[indexPath length] - 1]] label] retain];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ( ( [entries count] > 0 ) && ( [indexPath length] > 0 ) )
{
...
}
}
- (void)dealloc {
[super dealloc];
}
- (void) listLocalInstruments {
NSMutableArray *result = [NSMutableArray arrayWithCapacity:10];
[result addObject:[InstrumentDescriptor descriptorOn:[[NSBundle mainBundle] pathForResource:@"example" ofType:@"idl"] withLabel:@"Default 1"]];
[result addObject:[InstrumentDescriptor descriptorOn:[[NSBundle mainBundle] pathForResource:@"example" ofType:@"xml"] withLabel:@"Default 2"]];
[entries release];
entries = [[NSArray alloc] initWithArray:result];
}
@end
Run Code Online (Sandbox Code Playgroud)
RPM*_*RPM 91
Apple的文档说,didSelectRowAtIndexPath:index
调用时不会调用selectRowAtIndexPath:indexPath
它.要打电话请didSelectRowAtIndexPath
使用以下内容:
[[tableView delegate] tableView:tableView didSelectRowAtIndexPath:index];
这基本上调用了委托.
归档时间: |
|
查看次数: |
27384 次 |
最近记录: |