1時間前から解決できない小さな問題に遭遇しました... iOSは初めてなので、おそらく1秒後に気付くでしょう;) SOに関する類似の投稿を探していましたが、満足のいくものは見つかりませんでした答え...
上記のようにありSplitViewController
ます(XIBを使用して、左側にtableViewを追加し、右側にtextViewを追加しました)。プロジェクトをコンパイルして実行しようとすると、次のエラーが発生します。
スレッド 1: 受信シグナル「SIGABRT」をプログラムします。
tableView と textView を関連付けた 1 つの分割ビューが必要です。私が間違っていることは何ですか?
SplitViewController.h:
#import <UIKit/UIKit.h>
@interface SplitViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UITextView *textView;
@end
SplitViewController.m:
#import "SplitViewController.h"
@implementation SplitViewController
@synthesize tableView;
@synthesize textView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[self setTableView:nil];
[self setTextView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
@end
TestAppDelegate.h:
#import <UIKit/UIKit.h>
@class SplitViewContoller;
@interface TestAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIViewController *viewController;
@end
TestAppDelegate.m:
#import "TestAppDelegate.h"
#import "SplitViewController.h"
@implementation TestAppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[SplitViewController alloc] initWithNibName:@"SplitViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
}
- (void)applicationWillTerminate:(UIApplication *)application
{
}
@end
正確さのためだけにメイン:
#import <UIKit/UIKit.h>
#import "TestAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([TestAppDelegate class]));
}
}