我創建按鈕內部的下方顯示循環的代碼爲按鈕iOS應用崩潰單擊
for(int i=1;i<[_imageDetailsEntities count];i++)
{
UIButton *bttn=[UIButton buttonWithType:UIButtonTypeCustom];
bttn.frame=CGRectMake(x,y,75,75);
[_scrollView addSubview:bttn];
ImageDetails *imageDetails=[_imageDetailsEntities objectAtIndex:i];
UIImage *image= [self imageFromPath:imageDetails.imagePath];
[bttn setImage:image forState:UIControlStateNormal];
bttn.tag=i-1;
[bttn addTarget:self action:@selector(imageTapped:) forControlEvents:UIControlEventTouchUpInside];
x=bttn.frame.origin.x+bttn.frame.size.width+distanceBetweenButtons;
if(i%3==0)
{
x=29;
y=y+bttn.frame.size.height+20;
}
}
[_scrollView setContentSize:CGSizeMake(320,y+95)];
-(void)imageTapped:(id)sender
{
UIButton *bttn=(UIButton*)sender;
[_delegate didFinishChoosingImageAtIndex:bttn.tag];
}
應用與EXC_Bad接入消息崩潰時,我一個輕按button.I正在使用ARC。我不知道,我在這裏失蹤。請幫助我
你有沒有檢查_delegate。是零嗎? –
@ bit-whacker,這不是問題。如果他以編程方式添加事件,他可以使用void。 –
@Nishnat Tyagi我甚至通過評論該行代碼進行了檢查。但仍然崩潰 – Karthick