在 tableView
中,我有一些对象显示得很好。但是,当我与列表交互并向下(向前)滚动时,应用程序将崩溃。我以前从未见过这种情况,也不知道为什么会这样。我将第 3 方日历与我的代码结合使用,我认为我应该提及这一点,但我认为这不是主要问题。
#import "VRGViewController.h"
@interface VRGViewController ()
@end
@implementation VRGViewController{
NSArray *calendarTableData;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
VRGCalendarView *calendar = [[VRGCalendarView alloc] init];
calendar.delegate=self;
calendar.center = self.view.center;
[self.view addSubview:calendar];
calendarTableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto",nil];
}
-(void)calendarView:(VRGCalendarView *)calendarView switchedToMonth:(int)month targetHeight:(float)targetHeight animated:(BOOL)animated {
if (month==[[NSDate date] month]) {
NSArray *dates = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:5], nil];
[calendarView markDates:dates];
}
}
-(void)calendarView:(VRGCalendarView *)calendarView dateSelected:(NSDate *)date {
NSLog(@"Selected date = %@",date);
}
#pragma mark - User Defined Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [calendarTableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *simpleTableIdentifier = @"Services";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [calendarTableData objectAtIndex:indexPath.row];
return cell;
}
@end
最佳答案
您必须按以下方式声明您的数据源:
calendarTableData = [[NSArray alloc]initWithObjects:@"Egg Benedict",
@"Mushroom Risotto",nil];
关于ios - [__NSArrayI objectAtIndex :]: message sent to deallocated instance 0x7fbdae1a2080,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32685094/