ฉันประสบปัญหาขณะทำงานกับ UISwitch บน UITableView
แบบคงที่ ฉันต้องคืนค่าสถานะสุดท้ายของ UISwitch
บางค่าเมื่อโหลดแอป แต่เมื่อใดก็ตามที่ฉันตรวจสอบสถานะของ IBOutlet
ก็จะเป็นศูนย์ ฉันได้พยายามจัดสรรตัวแปรด้วยตนเอง ซึ่งก็ไม่ได้ช่วยอะไรเช่นกัน
นี่คือสิ่งที่ฉันทำ:
การตั้งค่าController.h
//IBOutlet connected correctly
@property (strong, nonatomic) IBOutlet UISwitch *switch_displayDetail;
การตั้งค่าController.m
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (!_switch_displayDetail) {
NSLog(@"_switch_displayDetail is NIL"); //This is always displayed
}
//Switch is default to YES, I am trying to set it to NO
//This line does nothing...
[_switch_displayDetail setOn:[dataManager shouldDisplayDetail] animated:YES];
}
ทุกที่อื่นๆ เมื่อฉันตรวจสอบสถานะของ _switch_displayDetail
จะไม่มีเลย ฉันกำลังเรียกวิธีการเริ่มต้นขั้นสูงทั้งหมด มีอะไรเปลี่ยนแปลงใน iOS 6.1 หรือไม่?
[แก้ไข] การใช้ตัวแปรสังเคราะห์ก็ไม่ได้ผลเช่นกัน
[แก้ไข 2] พบปัญหาว่าเป็นข้อบกพร่องใน Xcode หรือบน iPhone Simulator หลังจากการทดสอบบน iPod touch ของฉัน อัลกอริธึมเริ่มต้นทำงานได้อย่างสมบูรณ์แบบ
ฉันกำลังจะบ้ากับปัญหานี้ ...
initWithNibName
และไม่ใช่แค่init
บน SettingsController หรือไม่ - person Sathya   schedule 04.02.2013