将 UITableViewController 推送到 [self navigationController] 会导致 EXC_BAD_ACCESS
在我所处的当前视图中,按钮 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还请搞清楚你的内存管理,否则你会遇到更多问题。每次分配后都应该有一个释放或一个自动释放。
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.