在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:]:消息发送到已释放实例0x7fbdae1a2080,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32685094/