タブブラウジングを使用するアプリを作成しようとしています。ルート コントローラーを適切に指定する方法がわかりません。xcode でこのエラーが発生し続けます。
「2013-10-13 18:51:56.688 FoxSays[23795:a0b] アプリケーション ウィンドウには、アプリケーションの起動の最後にルート ビュー コントローラーが必要です」
アプリは起動しますが、白い画面が表示されます。これは、xcode がどの画面を表示すべきかを判断できないためだと言われています。
誰かが私を助けてくれることを期待して、私が持っているコードを投稿します。そこにはいくつかのランダムな未完成のものがありますが、今は先に進む前にそれを表示しようとしています. 前もって感謝します。
//
// FSAppDelegate.h
// FoxSays
//
// Created by Scott Pfeiffer on 10/1/13.
// Copyright (c) 2013 Bradley. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface FSAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
.
//
// FSAppDelegate.m
// FoxSays
//
// Created by Scott Pfeiffer on 10/1/13.
// Copyright (c) 2013 Bradley. All rights reserved.
//
#import <Parse/Parse.h>
#import "FSAppDelegate.h"
@implementation FSAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
//parse key
[Parse setApplicationId:@"cG4arrkdJdTSHMwczQ4EQ7Lhj1qWjnoGDjGxtVZg"
clientKey:@"xVgThu6c55mm6e0TOmBLc4u5T4KCV4yqReYkekUP"];
//parse analytics
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
.
//
// FSHomeViewController.h
// FoxSays
//
// Created by Scott Pfeiffer on 10/1/13.
// Copyright (c) 2013 Bradley. All rights reserved.
//
#import <AVFoundation/AVAudioPlayer.h>
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import "FSItemStore.h"
#import "FSItem.h"
@interface FSHomeViewController : UITabBarController
- (IBAction)playAudio:(id)sender;
@end
.
//
// FSHomeViewController.m
// FoxSays
//
// Created by Scott Pfeiffer on 10/1/13.
// Copyright (c) 2013 Bradley. All rights reserved.
//
#import "FSHomeViewController.h"
#import "FSItem.h"
#import "FSItemStore.h"
@interface FSHomeViewController ()
@property (weak, nonatomic) IBOutlet UIButton *playAudio;
@end
@implementation FSHomeViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)playAudio:(id)sender {
AVAudioPlayer *audioPlayer;
NSString *audioPath = [[NSBundle mainBundle] pathForResource:@"Woof" ofType:@"mp3"];
NSURL *audioURL = [NSURL fileURLWithPath:audioPath];
NSError *audioError = [[NSError alloc] init];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:&audioError];
if (!audioError) {
[audioPlayer play];
NSLog(@"Woof!");
}
else {
NSLog(@"Error!");
}
}
@end
.
//
// FSAnimalsViewController.h
// FoxSays
//
// Created by Scott Pfeiffer on 10/1/13.
// Copyright (c) 2013 Bradley. All rights reserved.
//
#import <AVFoundation/AVAudioPlayer.h>
#import <UIKit/UIKit.h>
#import "FSDetailViewController.h"
@interface FSAnimalsViewController : UITableViewController
{
}
@end
.
//
// FSAnimalsViewController.m
// FoxSays
//
// Created by Scott Pfeiffer on 10/1/13.
// Copyright (c) 2013 Bradley. All rights reserved.
//
#import "FSAnimalsViewController.h"
#import "FSItemStore.h"
#import "FSItem.h"
@implementation FSAnimalsViewController
- (id)init
{
// Call the superclass's designated initializer
self = [super initWithStyle:UITableViewStyleGrouped];
if (self)
{
UINavigationItem *n = [self navigationItem];
[n setTitle:@"FoxSays"];
// Create a new bar button item that will send
// addNewItem: to ItemsViewController
[[self navigationItem] setLeftBarButtonItem:[self editButtonItem]];
}
return self;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[self tableView] reloadData];
}
- (id)initWithStyle:(UITableViewStyle)style
{
return [self init];
}
- (void)tableView:(UITableView *)aTableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
FSDetailViewController *detailViewController = [[FSDetailViewController alloc] init];
NSArray *items = [[FSItemStore defaultStore] allItems];
FSItem *selectedItem = [items objectAtIndex:[indexPath row]];
// Give detail view controller a pointer to the item object in row
[detailViewController setItem:selectedItem];
// Push it onto the top of the navigation controller's stack
[[self navigationController] pushViewController:detailViewController
animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [[[FSItemStore defaultStore] allItems] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Set the cell identifier
static NSString *CellIdentifier = @"BasicCell";
// Reuse the cell from the identifier
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell if it doesn't exist
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Log the row for debugging
NSLog(@"%d", [indexPath row]);
// Get object from store
FSItem *item = [[[FSItemStore defaultStore] allItems] objectAtIndex:[indexPath row]];
// Set label to from property in object
[[cell textLabel] setText:[item title]];
return cell;
}