0

我遇到了一个小时后我无法解决的小问题......我是 iOS 新手,所以可能你会在一秒钟后注意到它;)我正在寻找关于 SO 的类似帖子,但没有找到令人满意的回答...

上面有一个SplitViewController(我使用XIB在左侧添加了一个tableView,在右侧添加了一个textView)。当我尝试编译和运行我的项目时,出现以下错误:

线程 1:程序接收到信号“SIGABRT”。

我想要一个与 tableView 和 textView 相关的拆分视图。我做错了什么?

拆分视图控制器.h:

#import <UIKit/UIKit.h>

@interface SplitViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UITextView *textView;

@end

拆分视图控制器.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]));
    }
}
4

0 回答 0