这是我第一次在这里写文章,但我有一个无法处理的问题:(...
当我在另一个表中推送单元格后推送 UITableView 时,问题就出现了,如果我创建一个通用 UITableViewController 并推送它,则可以工作,但如果我使用所有必要的方法重新定义类,则不起作用。
我之前在其他代码中实现过这个并且它可以工作,但是现在,更新到 Xcode 4.5 后,不起作用......
这是我要推送的 View 的源代码:
@interface ECDetailSettingsTableView ()
@end
@implementation ECDetailSettingsTableView
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ECDetailSettingsCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ECDetailSettingsCell"];
// Configure the cell...
return cell;
}
这是推送 tableview 的代码:
/********************* Pushing View *********************/
[tableView deselectRowAtIndexPath:indexPath animated: YES];
_themeTable = [self.storyboard instantiateViewControllerWithIdentifier:@"ECDetailSettingsViewController"];
[self.navigationController pushViewController:_themeTable animated:YES];
PD:谢谢大家,如果我犯了语法错误,很抱歉:)。
最佳答案
也许如果您在 Storyboard 中使用 segue
会生成错误,因为这仅适用于 iOS 6。
关于iphone - 应用程序在设备上崩溃,但在模拟器中推送 UITableView 时不会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12983299/