2017-10-03 8 views
0

私はTheOSを使用して脱獄アプリケーションを開発しています。ここで私のコードはテーブルビューのプログラムで、私はほとんどのテーブルビューメソッドを実装するための最も簡単な方法でした。テーブルビューはデフォルトのテーブルデータを正しく表示しますが、テーブルビューをスクロールするとアプリケーションがクラッシュします。私のエラーログには明白なログは表示されませんでした。 私を助けてください、私は実際には、ビューをスクロールしながらすぐにクラッシュする理由を見つけることができません。スクロール中にOS iOSプログラムでUITableviewコードがクラッシュする

#import "DeviceInfoTableViewController.h" 

@interface DeviceInfoTableViewController() 

@end 

@implementation DeviceInfoTableViewController 
{ 
    NSArray *tableData; 
} 

- (void)loadView { 
    [super loadView]; 
    self.title = @"Table View Controller"; 
} 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Initialize table data 
    tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil]; 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

#pragma mark - Table view data source 

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    NSLog(@"the tableData count: %ld", (unsigned long)tableData.count); 
    return tableData.count; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (!cell) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    NSString *str = tableData[indexPath.row]; 
    cell.textLabel.text = str; 
    return cell; 
} 

#pragma mark - Table view delegate 

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath: 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 

} 

@end 

ipsのクラッシュレポートにもアクセスしましたが、有用な情報は表示されませんでした。

エラーログ:

Oct 3 16:18:51: --- last message repeated 2 times --- 
Oct 3 16:18:51 iPhone ReportCrash[3617]: MS:Notice: Injecting: (null) [ReportCrash] (1141.16) 
Oct 3 16:18:51 iPhone ReportCrash[3617]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/0MobileGestaltFaker.dylib 
Oct 3 16:18:51 iPhone ReportCrash[3617]: MS:Error: binary does not support this cpu type 
Oct 3 16:18:51 iPhone ReportCrash[3617]: MS:Error: failure to check GoldPPServer.dylib 
Oct 3 16:18:51 iPhone ReportCrash[3617]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/RocketBootstrap.dylib 
Oct 3 16:18:51 iPhone ReportCrash[3617]: task_set_exception_ports(B07, 400, F03, 0, 0) failed with error (4: (os/kern) invalid argument) 
Oct 3 16:18:51 iPhone ReportCrash[3617]: ReportCrash acting against PID 3614 
Oct 3 16:18:51 iPhone ReportCrash[3617]: Formulating crash report for process testproject[3614] 
Oct 3 16:18:51 iPhone com.apple.xpc.launchd[1] (UIKitApplication:com.zxx.testproject[0x6965][3614]): Service exited due to signal: Segmentation fault: 11 
Oct 3 16:18:51 iPhone ReportCrash[3617]: Saved report to /Library/Logs/CrashReporter/testproject_2017-10-03-161851_iPhone.ips 
Oct 3 16:18:51 iPhone SpringBoard[3524]: Application 'UIKitApplication:com.zxx.testproject[0x6965]' crashed. 
Oct 3 16:18:51 iPhone assertiond[52]: pid_suspend failed for <BKNewProcess: 0x12fe2dfa0; com.zxx.testproject; pid: 3614; hostpid: -1>: Unknown error: -1, Unknown error: -1 
Oct 3 16:18:51 iPhone assertiond[52]: Could not set priority of <BKNewProcess: 0x12fe2dfa0; com.zxx.testproject; pid: 3614; hostpid: -1> to 2, priority: No such process 
Oct 3 16:18:51 iPhone assertiond[52]: Could not set priority of <BKNewProcess: 0x12fe2dfa0; com.zxx.testproject; pid: 3614; hostpid: -1> to 4096, priority: No such process 
Oct 3 16:18:51 iPhone UserEventAgent[44]: id=com.zxx.testproject pid=3614, state=0 
Oct 3 16:18:56 iPhone mstreamd[3606]: (Note) mstreamd: Not monitoring for external power. 
Oct 3 16:18:56 iPhone mstreamd[3606]: (Note) PS: Media stream daemon stopping. 
Oct 3 16:18:56 iPhone mstreamd[3606]: (Note) AS: <MSIOSAlbumSharingDaemon: 0x145e74010>: Shared Streams daemon has shut down. 
Oct 3 16:18:56 iPhone mstreamd[3606]: (Warn) mstreamd: mstreamd shutting down. 
Oct 3 16:18:56 iPhone mstreamd[3620]: MS:Notice: Injecting: com.apple.mediastream.mstreamd [mstreamd] (1141.16) 
Oct 3 16:18:56 iPhone mstreamd[3620]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/0MobileGestaltFaker.dylib 
Oct 3 16:18:56 iPhone mstreamd[3620]: MS:Error: binary does not support this cpu type 
Oct 3 16:18:56 iPhone mstreamd[3620]: MS:Error: failure to check GoldPPServer.dylib 
Oct 3 16:18:56 iPhone mstreamd[3620]: (Note) mstreamd: mstreamd starting up. 
Oct 3 16:18:56 iPhone mstreamd[3620]: (Note) PS: Media stream daemon starting... 
Oct 3 16:18:57 iPhone locationd[99]: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0 

私はこの方法によって、別のルートビューコントローラからこののtableViewを呼び出す:

- (void)deviceInfoTap:(id)sender { 
    DeviceInfoTableViewController *controller = [[DeviceInfoTableViewController alloc] init]; 
    [self.navigationController pushViewController:controller animated:YES]; 
} 
+0

私はあなたがセル、セル= [[[UITableViewCellのアロケーション] initWithStyleに自動解放を必要といけないと思います];それを取り出して再試行してください。 – GeneCode

+0

素早い返答をいただきありがとうございますが、私の解決策はまだクラッシュしました... Orz、他の解決策はありますか? –

+0

[tableView deselectRowAtIndexPath:indexPath animated:YES]をコメントアウトできますか?それでもクラッシュするかどうかを確認してください – GeneCode

答えて

0

おそらくそれが原因あなたたtableDataへの弱参照に起こりました。あなたたtableDataための強い参照を割り当てますのviewDidLoadで次に

@interface DeviceInfoTableViewController() 

@property (nonatomic, strong) NSArray *tableData; 

@end 

:UITableViewCellStyleDefault reuseIdentifier::CellIdentifier]自動解放

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Initialize table data 
    _tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil]; 
} 
+0

こんにちは、私はあなたのやり方を試していますが、まだクラッシュ....それはまた、データを正しく表示することができますが、スクロール時にクラッシュします。 –

関連する問題