1
我試圖使用導航控制器在兩個ViewControllers之間的過渡,由segue.destinationViewController引用的對象是:0x1cd93590(下一個視圖),但是當做出更改新近查看這個對象的數目是不同的:0x1cd4556d0。我的代碼是:IOS。 segue.destinationViewController對象是從加載控制器不同
- (void)updateCodeProduct:(NSString *)code {
[session stopRunning];
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(1111);
// db acces.
NSString *cadena = @"http://172.20.10.2/consultaProd.php?codigo=";
cadena = [cadena stringByAppendingString:codigo];
NSURL *url = [NSURL URLWithString:cadena];
NSError *error = nil;
NSString *retorno = [[NSString alloc] initWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];
if (retorno == nil) {
NSLog(@"Error %@\n%@", url, [error localizedFailureReason]);
return;
}
self.detailProd = nil;
self.detailProd = [retorno componentsSeparatedByString:@"\n"];
[self performSegueWithIdentifier:@"DetailSegue" sender:self];
}
的prepareForSegue方法是:進行
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"%@", [segue destinationViewController]);
if ([segue.identifier isEqualToString:@"DetailSegue"]) {
[segue.destinationViewController updateDetail:detailProd];
}
}
的SEGUE,但視圖不反映當前的信息,因爲是不同的對象。
任何幫助將不勝感激:)
感謝@Rob,方法-updateDetal屬於DetailViewControler,並更新了兩個UILabels,quote(如果它試圖更新目標控制器中的控件,現在這麼做還爲時過早,因爲控件不會被創建然而)。我更正這個創建NSString並更新-viewdidLoad方法中的標籤。並且工作正常....非常感謝。 :) – Menio