Я делаю приложение и использую в нем контроллер табличного вида и используя флажки в ячейке таблицы. все работают нормально, но когда я прокручиваю таблицу вниз, он работает нормально, но когда я просматриваю таблицу, то он дает исключение, упомянутое выше. Ниже приведен пример кода.Завершение приложения из-за неперехваченного исключения «NSInvalidArgumentException», причина: '- [UIButton setText:]
- (void)viewDidLoad {
[super viewDidLoad];
[checkimageArray removeAllObjects];
[lblArray removeAllObjects];
self.MainView.hidden=YES;
checkBoxesCount=0;
self.lblArray=[NSMutableArray new];
self.image.hidden=YES;
self.checkimageArray=[NSMutableArray new];
for (int i=0; i<15; i++) // when i decrease this loop to 12 it waz working fine but on 15 it is not working
{
[self.lblArray addObject:[NSString stringWithFormat:@"cell Number %d",i]];
}
[self.activitiesTableView_ reloadData];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.lblArray.count;
}
и это меня метод настройки ячеечная
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *tableviewidentifier = @"cell";
tablecellTableViewCell *cell= [self.activitiesTableView_ dequeueReusableCellWithIdentifier:tableviewidentifier];
if(cell==nil)
{
cell = [[tablecellTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableviewidentifier];
}if(indexPath.row == [self tableView:tableView numberOfRowsInSection:indexPath.section] - 1){
// [[cell textLabel] setText:@"Load more records"];
}
UILabel *valuedate = (UILabel *)[cell viewWithTag:11];
UILabel *msg = (UILabel *)[cell viewWithTag:12];
UILabel *date = (UILabel *)[cell viewWithTag:13];
UILabel *time = (UILabel *)[cell viewWithTag:14];
[valuedate setText:@"Demo"];
[msg setText:@"How are You?"];
[email protected]"14/07/2014";
[email protected]"A 08:16";
cell.image.layer.borderColor=(__bridge CGColorRef)([UIColor blackColor]);
cell.image.layer.borderWidth=2.0;
valuedate.font=[UIFont fontWithName:@"SegoeUI" size:15];
msg.font=[UIFont fontWithName:@"SegoeUI-light" size:10.0];
date.font=[UIFont fontWithName:@"SegoeUI-light" size:9];
time.font=[UIFont fontWithName:@"SegoeUI-light" size:9];
[cell.button setBackgroundImage:[UIImage imageNamed:@"uncheck.png"] forState:UIControlStateNormal];
[cell.button setImage:nil forState:UIControlStateNormal];
if ([self.checkimageArray containsObject:[self.lblArray objectAtIndex:indexPath.row]])
{
[cell.button setImage:[UIImage imageNamed:@"tick.png"]
forState:UIControlStateNormal];
cell.backgroundColor=[UIColor colorWithRed:(245/255.0) green:(245/255.0) blue:(245/255.0) alpha:1];
}
else
{
cell.backgroundColor=[UIColor clearColor];
}
cell.button.tag=indexPath.row;
[cell.button addTarget:self action:@selector(checkButton:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
Hey Mishal, Из журнала сбоев, Кажется, что вы даете прямой текст своему объекту UIButton. –
означает ??? я не могу получить u –
Можете ли вы предложить мне, в какой точной строке ваш код действительно сбой? Тогда вам будет немного легче дать вам указания. –