空き時間にiPadプログラムに取り組んでいますが、小さな問題に遭遇しました。私の uisplitview では、セルをクリックすると画像が読み込まれ、他に 2 つのセルがあり、クリックしたときのコードがそれぞれに表示されます
[self.icon1 removeFromSuperview];
ただし、これは画像を削除するのに問題なく機能します。写真でセル1をクリックした後...次にセル2をクリックすると(そしてこの削除コードが実行されます)、写真が正しく削除されます。しかし、セル3をクリックすると...プログラムが壊れます(アクセスが悪く、removeFromSuperviewを指しています)。アイコンが既に削除されているため、これが発生すると思います。基本的に「存在する場合はスーパービューから削除する」と言う機能はありますか? ありがとうございました
if (([receivedRainObject isEqualToString:@"Facts"]) && (Track==100)) {
self.view.backgroundColor=[UIColor whiteColor];
// self.tvFacts=[[UITextView alloc]initWithFrame:CGRectMake(0, 150, 700, 500)];
self.tvFacts.text=@" Test";
[tvFacts setEditable:NO];
UIImage *acheivement1=[UIImage imageNamed:@"saychesse.png"];
[factBanner1 setImage:acheivement1];
UIImage *fbIcon= [UIImage imageNamed:@"facebook.png"];
fbIcon1 = [UIButton buttonWithType:UIButtonTypeCustom];
fbIcon1.frame = CGRectMake(580.0, 305.0, 35.0, 35.0);
fbIcon1.tag=TAG_BUTTON_ONE;
[fbIcon1 addTarget:self action:@selector(authButtonAction) forControlEvents:UIControlEventTouchUpInside];
[fbIcon1 setBackgroundImage:fbIcon forState:UIControlStateNormal];
UIImage *twIcon= [UIImage imageNamed:@"twitter.png"];
twIcon1 = [UIButton buttonWithType:UIButtonTypeCustom];
twIcon1.frame = CGRectMake(530.0, 305.0, 35.0, 35.0);
[twIcon1 addTarget:self action:@selector(tweetTapped) forControlEvents:UIControlEventTouchUpInside];
[twIcon1 setBackgroundImage:twIcon forState:UIControlStateNormal];
[self.imgClassification removeFromSuperview];
[self.Image removeFromSuperview];
[self.lblSel removeFromSuperview];
[self.tvDescrip removeFromSuperview];
[self.tvName removeFromSuperview];
[self.tvDiet removeFromSuperview];
[self.navigationController popViewControllerAnimated:NO];
[self.lblPictureAnnotation removeFromSuperview];
[self.lbllife removeFromSuperview];
[self.tvGestation removeFromSuperview];
[self.view addSubview:self.tvFacts];
[self.view addSubview:factBanner1];
[self.view addSubview:fbIcon1];
[self.view addSubview:twIcon1];
[self.view setNeedsDisplay];
}
// Life-Span
if (([receivedRainObject isEqualToString:@"Life Span"]) && (Track==100)) {
self.view.backgroundColor=[UIColor whiteColor];
// self.lbllife=[[UILabel alloc]initWithFrame:CGRectMake(0, 150, 700, 500)];
self.lbllife.text=@"The";
[lbllife setEditable:NO];
[self.factBanner1 removeFromSuperview];
[self.fbIcon1 removeFromSuperview];
[self.twIcon1 removeFromSuperview];
[self.factBanner2 removeFromSuperview];
[self.fbIcon2 removeFromSuperview];
[self.twIcon2 removeFromSuperview];
[self.imgClassification removeFromSuperview];
[self.Image removeFromSuperview];
[self.lblSel removeFromSuperview];
[self.tvDescrip removeFromSuperview];
[self.tvName removeFromSuperview];
[self.tvDiet removeFromSuperview];
[self.navigationController popViewControllerAnimated:NO];
[self.tvFacts removeFromSuperview];
[self.lblPictureAnnotation removeFromSuperview];
[self.tvGestation removeFromSuperview];
[self.factBanner1 removeFromSuperview];
[self.view addSubview:self.lbllife];
[self.view setNeedsDisplay];
}