我有一个 UITableView 并在其中我以以下方式创建了一个自定义 UITableViewCell:
ItemCellController *cell = (ItemCellController *)[tableView dequeueReusableCellWithIdentifier:ContentListsCellIdentifier];
...
cell = [[[ItemCellController alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ContentListsCellIdentifier] autorelease];
我这样做是为了获得 touchesBegan 和 touchesEnded 事件(这样我就可以实现长触摸)。使用 NSLog 我可以看到使用以下代码从 touchesBegan 方法中正确调用了 longTouch:
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(longTouch:) userInfo:nil repeats:YES];
问题是我无法从 longTouch 方法中调用模式窗口。
我尝试了以下方法,但我得到一个 NSInvalidArgumentException -[ItemCellController navigationController]: unrecognized selector sent to instance 错误。
AddItemController *addView = [[AddItemController alloc] initWithNibName:@"AddItemView" bundle:nil];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:addView];
controller.navigationBar.barStyle = UIBarStyleBlack;
[[self navigationController] presentModalViewController:controller animated:YES];
[controller release];
所以问题是,如何从自定义 UITableViewCell 中调用模式窗口。
谢谢