1

アプリケーションからビューにアクセスしようとするたびに、アプリケーションがすぐに閉じます。NSZombieEnabled をアクティブ化するログをキャプチャしました。これが私が得たものです:

    *** -[RecargaOtroController tableView:cellForRowAtIndexPath:]: message sent to deallocated instance 0x604fd20
(gdb) info malloc-history 0x604fd20
Alloc: Block address: 0x0604fd20 length: 192
Stack - pthread: 0xa07c6540 number of frames: 38
    0: 0x955250a3 in malloc_zone_calloc
    1: 0x95524ffa in calloc
    2: 0x10a62d4 in class_createInstance
    3: 0xe725d8 in +[NSObject(NSObject) allocWithZone:]
    4: 0xe723da in +[NSObject(NSObject) alloc]
    5: 0x519c3b in -[UIClassSwapper initWithCoder:]
    6: 0x6039fd in UINibDecoderDecodeObjectForValue
    7: 0x6046ac in -[UINibDecoder decodeObjectForKey:]
    8: 0x51993e in -[UIRuntimeConnection initWithCoder:]
    9: 0x6039fd in UINibDecoderDecodeObjectForValue
   10: 0x6032f5 in UINibDecoderDecodeObjectForValue
   11: 0x6046ac in -[UINibDecoder decodeObjectForKey:]
   12: 0x518c36 in -[UINib instantiateWithOwner:options:]
   13: 0x51aab7 in -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:]
   14: 0x3d0628 in -[UIViewController _loadViewFromNibNamed:bundle:]
   15: 0x3ce134 in -[UIViewController loadView]
   16: 0x3ce00e in -[UIViewController view]
   17: 0x3cc482 in -[UIViewController contentScrollView]
   18: 0x3dcf25 in -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:]
   19: 0x3db555 in -[UINavigationController _layoutViewController:]
   20: 0x3dc7aa in -[UINavigationController _startTransition:fromViewController:toViewController:]
   21: 0x3d732a in -[UINavigationController _startDeferredTransitionIfNeeded]
   22: 0x3de562 in -[UINavigationController pushViewController:transition:forceImmediate:]
   23: 0x3d71c4 in -[UINavigationController pushViewController:animated:]
   24: 0x560e in -[RootViewController tableView:didSelectRowAtIndexPath:] at /Users/ipoletti/Documents/Recargame2/Recargame2/Classes/RootViewController.m:378
   25: 0x395b68 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]
   26: 0x38bb05 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:]
   27: 0x9d79e in __NSFireDelayedPerform
   28: 0xf2f8c3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
   29: 0xf30e74 in __CFRunLoopDoTimer
   30: 0xe8d2c9 in __CFRunLoopRun
   31: 0xe8c840 in CFRunLoopRunSpecific
   32: 0xe8c761 in CFRunLoopRunInMode
   33: 0x17851c4 in GSEventRunModal
   34: 0x1785289 in GSEventRun
   35: 0x32cc93 in UIApplicationMain
   36: 0x2a3c in main at /Users/.../Documents/Recargame2/Recargame2/main.m:14
   37: 0x29cd in start

明らかにtableViewが問題ですが、何が問題なのかわかりません。Interface Builder でどのようにリンクする必要がありますか? 私は .h にこれを持っています:

    @interface RecargaOtroController : UIViewController <UINavigationControllerDelegate, UITableViewDataSource, UITableViewDelegate>{
        BOOL agrandaRecarga;
    }

    IBOutlet UITableView *tableView;
    @property (nonatomic, retain)IBOutlet UITableView *tableView;

UITextField *myLoc;
@property (nonatomic, retain)UITextField *myLoc;

これはtableViewに関する私の.mの一部です(私はそれを合成しました):

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
    NSLog(@"TABLE VIEW: %@",tableView);
    NSLog(@"CELL");
    static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell==nil){
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]autorelease];
    }

    int r, g, b;
    b = 0x005C84 & 0x0000FF;
    g = ((0x005C84 & 0x00FF00) >> 8);
    r = ((0x005C84 & 0xFF0000) >> 16);
    UIColor *movistarColor = [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:100.0f];
    cell.detailTextLabel.font = [UIFont fontWithName:@"Verdana" size:15.0];
    cell.detailTextLabel.textColor = movistarColor;
    cell.textLabel.font = [UIFont fontWithName:@"Verdana-Bold" size:14.0];
    cell.textLabel.textColor = movistarColor;

    if([ListaNumerosController hayDefault]==nil){
        NSLog(@"NO HAY NUMEROS CARGADOS");
        if(indexPath.row == 0){
            cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ (%@)", tarjetaSeleccionada.alias, tarjetaSeleccionada.numero];
        }else if(indexPath.row == 1){
            cell.detailTextLabel.text = @"Otro";
        }else if(indexPath.row == 2){
            myLoc = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 250, 40)];
            myLoc.adjustsFontSizeToFitWidth = YES;
            myLoc.textColor = movistarColor;
            myLoc.textAlignment = UITextAlignmentLeft;
            myLoc.highlighted = NO;
            myLoc.clearsContextBeforeDrawing=YES;
            myLoc.placeholder = @"Ingrese su número";

            myLoc.delegate = self;
            myLoc.font = [UIFont fontWithName:@"Verdana" size:14.0];
            myLoc.clearButtonMode = UITextFieldViewModeNever; // no clear 'x' button to the right
            if(myLoc.text.length!=10){
                [myLoc becomeFirstResponder];
            }
            [myLoc setKeyboardType: UIKeyboardTypeNumberPad];
            [myLoc setEnabled:YES];
            [cell addSubview:myLoc];
        }else /*if(indexPath.row == 3)*/{
            cell.detailTextLabel.text = recarga.monto;
        }
    }else{
        NSLog(@"HAY NUMEROS CARGADOS");
        if(![telefonoSeleccionado.alias isEqualToString:@"Otro"]){
            NSLog(@"NO SE SELECCIONO OTRO NUMERO");
            if(indexPath.row == 0){
                cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ (%@)", tarjetaSeleccionada.alias, tarjetaSeleccionada.numero];
            }else if(indexPath.row == 1){
                cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ (%@)",telefonoSeleccionado.alias,[telefonoSeleccionado.telefono substringFromIndex:6]];
            }else if(indexPath.row == 2){
                cell.detailTextLabel.text = recarga.monto;
                myLoc.text = @"";
            }else if(indexPath.row == 3){
                cell.detailTextLabel.text = @"";
            }
        }else{
            NSLog(@"SE SELECCIONO OTRO NUMERO");
            if(indexPath.row == 0){
                cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ (%@)", tarjetaSeleccionada.alias, tarjetaSeleccionada.numero];
            }else if(indexPath.row == 1){
                cell.detailTextLabel.text = @"Otro";
            }else if(indexPath.row == 2){
                cell.detailTextLabel.text = @"";
            }else if(indexPath.row == 3){
                cell.detailTextLabel.text = recarga.monto;
            }
        }
    }

    return cell;

}

- (void)dealloc {
    [super dealloc];    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    // Start listening for updates when visable
   [tableView setDelegate:self];
    [tableView reloadData];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    // Stop listening for updates when not visable
    [tableView setDelegate:nil];
}

問題はInterface Builderファイルにあるのではないかと考えています。何が問題なのかを理解する方法はありますか?

ありがとう!

更新: 私のアプリケーションは、テーブルを含むメイン ウィンドウで構成されています。各行をクリックすると、別のビューに移動します。新しいビュー (RecargaOtroController) には別のテーブルがあります。別のコントローラーを使用して、同じ方法で各ビューをインスタンス化します。

ThirdViewController.h

#import <UIKit/UIKit.h>


@interface ThirdViewController : UIViewController {

}

@end

ThirdViewController.m

#import "ThirdViewController.h"


@implementation ThirdViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
    [super viewDidUnload];
}


- (void)dealloc {
    [super dealloc];
}

次に、メイン画面である私の RootViewController:

RootViewController.h (抜粋)

#import <UIKit/UIKit.h>

@interface RootViewController : UITableViewController <UIAlertViewDelegate, UINavigationControllerDelegate, UITableViewDataSource, UITableViewDelegate> {
    NSMutableArray *opcionesMenu;
    BOOL agrandaRecarga;
}

IBOutlet UITableView *tableView;
@property (nonatomic, retain)IBOutlet UITableView *tableView;

RootViewController.m (抜粋)

ThirdViewController *detailViewController = nil;

if (indexPath.row == 1) {
            [self showConfirmaRecargaMessage];
            return;
        }else if (indexPath.row == 2) {
            detailViewController = [[RecargaOtroController alloc] initWithNibName:@"RecargaOtro" bundle:nil];
            detailViewController.title = @"Recargar otro número o monto";
        }else if (indexPath.row == 3) {

...

- (void)dealloc {
    [super dealloc];
}

RecargaOtroController の割り当てを解除することはありません (また、インスタンス化する画面のどのクラスも、とにかく、それらは常に機能していました)。

4

0 に答える 0