ラベルのテキストを変更しようとすると何らかの理由でクラッシュするというコードがあります。 UILabelに値を割り当てるときにシミュレータがクラッシュする
- (void) viewDidLoad {
[super viewDidLoad];
NSString * path = [[NSBundle mainBundle] pathForResource:@"Subs" ofType:@"plist"];
NSMutableDictionary * modelDict = [NSMutableDictionary dictionaryWithContentsOfFile:path];
NSDictionary * yearDict = [modelDict valueForKey:Sub_Model];
for (NSString * yearKey in yearDict) {
NSDictionary * sizeDict = [yearDict valueForKey:yearKey];
mount_depth = round([[[sizeDict valueForKey:Sub_Size] objectForKey:@"Mounting Depth"] floatValue]);
displacement = round([[[sizeDict valueForKey:Sub_Size] objectForKey:@"Displacement"] floatValue]);
sealed_min = [[[sizeDict valueForKey:Sub_Size] objectForKey:@"Sealed Min."] floatValue];
sealed_max = [[[sizeDict valueForKey:Sub_Size] objectForKey:@"Sealed Max."] floatValue];
ported_min = [[[sizeDict valueForKey:Sub_Size] objectForKey:@"Ported Min."] floatValue];
ported_max = [[[sizeDict valueForKey:Sub_Size] objectForKey:@"Ported Max."] floatValue];
minportlen = [[sizeDict valueForKey:Sub_Size] objectForKey:@"Min. Port Len."];
maxportlen = [[sizeDict valueForKey:Sub_Size] objectForKey:@"Max. Port Len."];
}
// [self loadEnclosure];
portlenLbl.hidden = FALSE;
}
は、それから私は、どのようなユーザーが選択に応じてラベルを変更するには、ナビゲーションアイテムのセグメント化されたコントロールを持っており、彼らはデフォルト以外を選択したときにときに、プログラムがクラッシュしたものです。
- (IBAction) boxSize:(id)sender {
// [self loadEnclosure];
switch (self.boxControl.selectedSegmentIndex) {
case 0:
portlenLbl.text = (@"%@", minportlen);
break;
case 1:
portlenLbl.text = (@"%@", maxportlen);
break;
default:
break;
}
}
私はまた、複数のビューは、このポイントに入る前にあることを追加する必要があり、彼らは「再これと同様の方法を使用して呼び出さ:
- (IBAction) GetBox:(id)sender {
K_Box * KView = [[K_Box alloc] initWithNibName:nil bundle:nil];
KView.Num_Subs = self.Num_Subs;
KView.Box_Type = self.Box_Type;
KView.Box_Shape = self.Box_Shape;
KView.Sub_Model = self.Sub_Model;
KView.Sub_Size = self.Sub_Size;
[self presentModalViewController:KView animated:YES];
}
投稿を編集するには十分な評判がありません。コードタグを使用してもう少し正確に整列してください。 //編集:ありがとう@aBitObvious –
ええ、私はそれがファンキーな出てきたようにあなたが投稿したときにそれを編集していた。ごめんなさい。 –
が実現しました。ライブプレビューがありますか? – vikingosegundo