タブ付きのアプリがあり、テーブルリストからページの詳細をロードします。
私の appDelegate.mi には次の関数があります。
@synthesize DetailController = _DetailController;
-(void)loadDetails{
[[self navigationController]pushViewController:_DetailController animated:YES];
}
ビュー firstviewController から呼び出します
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[[self appDelegate] setCurrentlySelectedBlogItem:[[[self rssParser]rssItems]objectAtIndex:indexPath.row]];
[[self appDelegate] loadDetails];
}
ただし、ビューを変更しないでください。なんで?
私のappDelegate.hで
#import <UIKit/UIKit.h>
@class FirstViewController;
@class DetailViewController;
@class RSSEntry;
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>{
UIWindow * _window;
FirstViewController * _viewController;
UINavigationController * _navigationController;
DetailViewController * _DetailController;
RSSEntry * _currentlySelectedBlogItem;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;
@property (nonatomic, strong) IBOutlet FirstViewController *viewController;
@property (nonatomic, strong) IBOutlet UINavigationController * navigationController;
@property (nonatomic,strong) IBOutlet DetailViewController * DetailController;
@property (readwrite,strong) RSSEntry * currentlySelectedBlogItem;
-(void)loadDetails;
@end