在这上花了好几个小时,找不到解决方案。我也用这个指南来帮助我: http://www.raywenderlich.com/29469/ipad-for-iphone-developers-101-in-ios-6-uisplitview-tutorial
我有一个通用应用程序,在iPad故事板中我有一个拆分视图控制器设置。我遇到的问题是细节视图没有更新其标签。
以下是一些代码段。
ContactsViewController.h(主视图)
@property(nonatomic,assign)id delegate;
@property(强,非原子)ContactsDetailsViewController * contactsDetailsVC;
ContactsViewController.m
self.contactsDetailsVC = (ContactsDetailsViewController *)[self.splitViewController.viewControllers lastObject];
self.delegate = self.contactsDetailsVC;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath *selectedRowIndex = [self.customTableView indexPathForSelectedRow];
id contactsList;
Contact *aContact;
if ([self.searchDisplayController isActive]) {
selectedRowIndex = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
contactsList = [self.searchedContactsArray objectAtIndex:selectedRowIndex.row];
aContact = contactsList;
}
else {
contactsList = [self.filteredListArray objectAtIndex:selectedRowIndex.section];
aContact = (Contact*)[[contactsList contactsList] objectAtIndex:selectedRowIndex.row];
}
if (self.delegate)
[self.delegate selectedContact:aContact];
}
ContactsDetailsViewController.h(详情视图)
@interface ContactsDetailsViewController : UIViewController <UISplitViewControllerDelegate, ContactSelectionDelegate>
ContactsDetailsViewController.m
- (void)setContactDetails:(Contact *)aContact
{
//Make sure you're not setting up the same contact.
if (_aContact != aContact)
_aContact = aContact;
self.name = aContact.name;
self.department = aContact.department;
self.email = aContact.email;
self.skype = aContact.skypeID;
self.telephone = aContact.telephone;
self.division = aContact.division;
self.contactImage = aContact.cachedImage;
}
- (void)selectedContact:(Contact *)newContact
{
[self setContactDetails:newContact];
}
ContactSelectionDelegate.h
@class Contact;
@protocol ContactSelectionDelegate <NSObject>
@required
- (void)selectedContact:(Contact *)newContact;
@end
如果有人可以指出我错过了什么,因为我真的需要解决这个问题,我们将非常感激。
如果您有任何其他问题,请告诉我。
谢谢。