在tableView
我有幾個對象顯示出來很好。但是,當我與列表交互並向下滾動(向前)時,應用程序將崩潰。我從來沒有見過這個,並沒有意識到爲什麼會發生這種情況。我將第三方日曆與我的代碼結合使用,我想我應該提到這一點,但我不認爲這是主要問題。[__NSArrayI objectAtIndex:]:發送到釋放實例的消息0x7fbdae1a2080
#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
非常感謝!工作@meda –