2012-04-18 6 views
4

ARCを利用したプロジェクトで簡単なUItableviewアプリケーションを作成しようとしています。テーブルはうまくレンダリングされますが、スクロールしたりセルをタップしようとすると、アプリがクラッシュします。 NSZombiesを見るとUITableViewがスクロールしたり、ARCでタップしたりするとクラッシュしますか?

(それを言うために、その適切な方法は何ですか?)私はメッセージを取得する -

を「[PlacesViewController respondsToSelector::]割り当て解除インスタンスに送信されたメッセージは0x7c29240」私はこれとは何かを持っていると信じてARCは私が過去にUItableviewsを正常に実装したが、これはARCを使用した私の最初のプロジェクトです。私は非常にシンプルなものを見逃しているに違いないことを知っ

PlacesTableViewController.h

@interface PlacesViewController : UIViewController 
<UITableViewDelegate,UITableViewDataSource> 

@property (nonatomic, strong) UITableView *myTableView; 

@end 

PlacesTableViewController.m

#import "PlacesTableViewController.h" 

@implementation PlacesViewController 

@synthesize myTableView; 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    self.myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; 

    self.myTableView.dataSource = self; 
    self.myTableView.delegate = self; 

    [self.view addSubview:self.myTableView]; 
} 
#pragma mark - UIViewTable DataSource methods 

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 100; 
} 



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *result = nil; 

    static NSString *CellIdentifier = @"MyTableViewCellId"; 

    result = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if(result == nil) 
    { 
     result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    result.textLabel.text = [NSString stringWithFormat:@"Cell %ld",(long)indexPath.row]; 


    return result; 
} 
@end 
+0

PlacesViewControllerの割り当て、初期化、および保存に使用するコードを取得できますか? – hukir

答えて

1

あなたが投稿したコードと、明らかに間違っては何もありません。問題は、PlacesViewControllerを作成して保持するコードの問題です。あなたはおそらくそれを作成していますが、どこにでも永続的に格納していませんPlacesViewControllerをivarに保存するか、それを管理するビューコンテナに入れておく必要があります(UINavigationController、UITabControllerなど)

+0

はい、何か問題がありました。ソリューションは、tableViewを保持するUIViewControllerの世話をしています。ちょうどそれに強い参照を置くようにしてください。 – rcmcastro

関連する問題