私はIOS開発の初心者です。 私はStoryboardを使用してUITableViewを作成しようとしましたが、このアプリケーションを実行すると「プログラム受信信号: 'SIGKILL'」と表示されます。UITableViewの "SIGKILL"エラーを解決する方法(Storyboardを使用してテーブルビューを構築した場合)
ストーリーボード(ARCなし)を使用してテーブルを作成しましたが、実行時に問題があります。ここ は、コード内で与えられた:
#import "MainTableViewController.h"
@interface MainTableViewController()
@property (strong, nonatomic) NSMutableArray *myArray;
@end
@implementation MainTableViewController
@synthesize myArray;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
myArray = [NSMutableArray arrayWithObjects:@"apple",@"orange",@"bananas", nil];
}
- (void)viewDidUnload
{
[super viewDidUnload];
self.myArray = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [myArray 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];
}
cell.textLabel.text = [myArray objectAtIndex:indexPath.row]; // 这儿出现异常 Program received signal: “SIGKILL”
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ }
@end
を私は、画面上で上下に移動し、このランタイムエラーが発生します。 ゾンビ機能を有効にしました。私は "myArray"がNSZombieオブジェクトであることを発見しました
そして、デバッグを続行します。 と同じ行に別のエラー "EXC_BAD_ACCESS"が見つかりました。 cell.textLabel.text = [myArray objectAtIndex:indexPath.row]; myArrayはまだゾンビオブジェクトです。
どのように解決しますか? ありがとうございました! !
これは、これらの種類の質問に対する正式な回答である必要があります。なぜ、私たちは標準的な答えを持っていないのですか? – jrturton
+1:この質問をお気に入りの質問に追加しました。 –