我簡單的認爲是一個UINavigationController的第三級,這表明從筆尖一個空表,這裏是.m文件的代碼:的iOS - UITableViewCell的初始化失敗,EXC_BAD_ACCESS
#import "ThirdLevel.h"
@implementation ThirdLevel
@synthesize lista, categoria;
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"Categoria: %@", categoria);
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return NO;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 20;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//newtableView.separatorColor = [UIColor clearColor];
static NSString *CellIdentifier = "Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
}
- (void)buttonPressed:(id)sender {
NSLog(@"premuto");
}
- (void)dealloc {
[super dealloc];
}
@end
當我運行它,設備死機和調試器說是有這條線一EXC_BAD_ACCESS:
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
我相同的代碼在UINavigationController的第二個層次,它做工精細,真的不要」不明白什麼是錯的。
感謝所有幫助:)
當添加
@
......難以置信......叫我白癡:d非常感謝你:) –我不明白他們爲什麼不要閱讀警告...... – Nekto
@Marco Faion在這個世界上沒有人是完美的..practice會讓我們變得最好。就是這樣。酷。 –