我有一個非常基本的通用應用程序。這是一個主要的細節。當我從主人繼續細節時,我將文本設置在標籤中,並使用NSString設置目標視圖控制器的標題。這在iPhone上運行良好,但在iPad上,它沒有設置標題或標籤。這裏是我用來設置一切的代碼:在分割視圖中執行「準備加入」方法
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSString *object = dailyGramsNumbers[indexPath.row];
NSString *object1 = dailyGramsBody [indexPath.row];
[[segue destinationViewController] setDetailItem:object1];
[[segue destinationViewController] setTitle:object];
}
}
感謝您的任何幫助!
這裏是我現在使用的代碼(除了上面的代碼):
- (void)tableView:
(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
NSString *object = dailyGramsNumbers[indexPath.row];
[self.splitViewController.viewControllers[1] setTitle:object];
self.detailViewController.detailItem = object;
}
}
您使用的是SplitViewController?在那種情況下,我想,在iPad上不會執行Segue,因爲兩個部分(主要和細節)都顯示在一起。我只是猜測,但也許這有助於 – Stefan
是的,這是我的想法。但我只是想弄清楚如何以相同的方式在分割視圖上執行該代碼。 –