将 UITableViewController 推送到 [self navigationController] 会导致 EXC_BAD_ACCESS

发布于 2024-09-09 18:00:29 字数 1416 浏览 2 评论 0原文

在我所处的当前视图中,按钮 touch-up-inside 事件会导致以下操作:(

请注意,在调试器中,我已经验证了 [self navigationController] 和实例化的 historyViewController 确实存在。

我无法确定为什么会发生这种错误的访问,我可以从导航控制器中弹出/推送此视图/其他视图。 em>这个视图在被推到导航控制器上时特别有问题?


-(IBAction) viewOrEditHistory: (id) sender {
    HistoryViewController *historyViewController = [[HistoryViewController alloc] initWithStyle:UITableViewStyleGrouped];
    historyViewController.title = @"View or Edit by date";
    historyViewController.sameExSessions = [[NSMutableArray alloc] init];
    historyViewController.exercise = [[Exercise alloc] initWithName:self.title muscleGroup:muscleGroupLabel.text];

/*** EXC_BAD_ACCESS happens after following line is executed ***/
    [[self navigationController] pushViewController:historyViewController animated:YES];
}

这是我的 HistoryViewController.h


#import 

@interface HistoryViewController : UITableViewController {

    NSMutableArray *sameExSessions;
    Exercise *exercise;

}
@property (nonatomic, retain) NSMutableArray *sameExSessions;
@property (nonatomic, retain) Exercise *exercise;

-(NSMutableArray *) SameExerciseSessionList;
-(NSString *) getDocPath;
-(NSInteger) tableView:(UITableView *) tableView numberOfRowsInSection: (NSInteger)section;
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath;

@end

In the current view that I am in, a button touch-up-inside event leads to the following action:

(Note that while in the Debugger, I've verified that both [self navigationController] and the instantiated historyViewController do indeed exist.

I am unable to determine why this bad access is happening. I can pop/push this view/other views from the navigation controller. Any ideas on how to go about investigating why this view in particular is having problems when getting pushed onto the nav controller?


-(IBAction) viewOrEditHistory: (id) sender {
    HistoryViewController *historyViewController = [[HistoryViewController alloc] initWithStyle:UITableViewStyleGrouped];
    historyViewController.title = @"View or Edit by date";
    historyViewController.sameExSessions = [[NSMutableArray alloc] init];
    historyViewController.exercise = [[Exercise alloc] initWithName:self.title muscleGroup:muscleGroupLabel.text];

/*** EXC_BAD_ACCESS happens after following line is executed ***/
    [[self navigationController] pushViewController:historyViewController animated:YES];
}

Here is my HistoryViewController.h


#import 

@interface HistoryViewController : UITableViewController {

    NSMutableArray *sameExSessions;
    Exercise *exercise;

}
@property (nonatomic, retain) NSMutableArray *sameExSessions;
@property (nonatomic, retain) Exercise *exercise;

-(NSMutableArray *) SameExerciseSessionList;
-(NSString *) getDocPath;
-(NSInteger) tableView:(UITableView *) tableView numberOfRowsInSection: (NSInteger)section;
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath;

@end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘落散花 2024-09-16 18:00:29

还请搞清楚你的​​内存管理,否则你会遇到更多问题。每次分配后都应该有一个释放或一个自动释放。

Please also get your memory management straight or you will run into a lot more problems. Every alloc should be followed by either a release or an autorelease.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文