iOS 9.3.5を実行している一部の古いハードウェアでは不思議な問題が発見されましたが、これがどうして起こるのか本当に感謝しています。私はシングルトン・グローバルでこの問題を回避することができますが、これはとても醜いようです。iOS Segueでの下位互換性問題
悪いケースでは、segueによるデータ転送は新しいView Controllerには届きませんが、9.3.5を実行している古いハードウェアとすべての新しいハードウェアはすべて正常に動作します。
簡単に言えば、Interface Builder(標準テンプレートではありません)で構築したMaster/Detailデザインを使用するAppがあります。メインのViewControllerにはUITableViewが含まれ、STCollapseライブラリとMMDrawerSideSlideライブラリの両方が使用されます。テーブル行を選択するとsegueが生成され、prepareForSegueはDetailViewControllerのプロパティにいくつかの項目をロードします。 NSStringプロパティは常にOKになりますが、古いハードウェア(下記参照)では、選択された行のNSIndexPathがメインVCのprepareForSegueのディテールのプロパティに正しく移動されますが、DetailViewControllerには届かず、プロパティはNILですディテールのviewDidLoadが実行されます。 selectedIndex
とsearchName
ためDetailViewController
表
iPad 2 9.3.5 nil
iPad Air 9.3.5 nil
iPad Air2 9.3.5 correct
iPhone 5 9.3.5 nil
iPhone 5s 9.3.5 correct
iPhone 6 9.3.5 correct
all devices 10.x correct
コードスニペット
メインViewController.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.selectedIndexPath = indexPath;
[self performSegueWithIdentifier:@"toDetail" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([[segue identifier] isEqualToString:@"toDetail"])
{
DetailViewController *detailVC = segue.destinationViewController;
detailVC.selectedIndex = self.selectedIndexPath;
detailVC.searchName = _theName;
}
}
DetailViewController.h
@property (nonatomic, weak) NSIndexPath * selectedIndex;
@property (nonatomic, weak)NSString * searchName;
DetailViewController.m
- (void)viewDidLoad { //In new hardware _selectedIndex is OK, in some old hardware, is nil, _searchName is always OK!
[super viewDidLoad];
Kings *flatkings = [Kings sharedKings];
self.flatSequenceNumber = (int)[flatkings getFlatIndexFromTablePath:_selectedIndex];
[self drawTheView];
}
Good Point!コピーでなければなりません。しかし、NSStringが常に正しく渡されている間は、indexPathが特定のハードウェアではなくnilになることはありません。私はindexPathのグローバル参照を追加することによって一時的に変更しましたが、潜在的な障害メカニズムを理解したいと思います。 – BlueskyMed
あなたは基本的に、コードのバグを書いています。このバグは、SDKの一部のバージョンではうまくいっています。 – jlehr
満足できるものではありませんが、おそらく本当です;) – BlueskyMed