【发布时间】:2014-03-10 22:26:42
【问题描述】:
我是 iOS 开发的新手,在尝试将开源 Wheel Rotating 项目 (https://github.com/funkyboy/How-To-Create-a-Rotating-Wheel-Control-with-UIKit) 嵌入我的项目时遇到了这个问题。
基本上,我把这个开源项目的相关代码文件和资产复制到我的,并做了一些必要的修改,希望它能运行。
“转轮组件”来自原始开源项目,“心情轮盘”是我的项目。
这是项目结构的屏幕截图:
还有堆栈跟踪:
2014-03-10 13:06:12.865 Mood Roulette[13125:60b] cl is 7 | 0.392699, 0.785398, 1.178097
2014-03-10 13:06:12.866 Mood Roulette[13125:60b] -[UCViewController wheelDidChangeValue:]: unrecognized selector sent to instance 0x146d175f0
2014-03-10 13:06:12.869 Mood Roulette[13125:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UCViewController wheelDidChangeValue:]: unrecognized selector sent to instance 0x146d175f0'
*** First throw call stack:
(0x18ba1f09c 0x19799dd78 0x18ba23d14 0x18ba21a7c 0x18b9414ac 0x1000c05fc 0x1000bfb44 0x1000c26f4 0x18e8f42c0 0x18e8f4044 0x18e8fb7dc 0x18e8f8ab0 0x18e96c88c 0x18e9691f0 0x18e9629a0 0x18e8f5530 0x18e8f4720 0x18e9620b0 0x191345128 0x191344c54 0x18b9defc8 0x18b9def28 0x18b9dd14c 0x18b91db38 0x18e9612d4 0x18e95c0e8 0x1000c24b8 0x197f87aa0)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
======
错误点在第100行
[self.delegate wheelDidChangeValue:[self getCloveName:currentValue]];
代码:
这是我更改的部分(主要是在ViewControllers 中进行的更改):
UCAppDelegate.h:
#import <UIKit/UIKit.h>
//@class UCViewController;
@interface UCAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
//@property (strong, nonatomic) UCViewController *viewController;
@end
UCAppDelegate.m:
@implementation UCAppDelegate
//@synthesize window;
//@synthesize viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// self.window.rootViewController = self.viewController;
// [self.window makeKeyAndVisible];
return YES;
}
UCViewController.h
#import <UIKit/UIKit.h>
#import "SMRotaryProtocol.h"
@interface UCViewController : UIViewController
@property (nonatomic, strong) UILabel *valueLabel;
@end
UCViewController.m:
#import "UCViewController.h"
#import "SMRotaryWheel.h"
@interface UCViewController ()
@end
@implementation UCViewController
@synthesize valueLabel;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 350, 120, 30)];
valueLabel.textAlignment = NSTextAlignmentCenter;
valueLabel.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:valueLabel];
SMRotaryWheel *wheel = [[SMRotaryWheel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)
andDelegate:self
withSections:8];
wheel.center = CGPointMake(160, 240);
[self.view addSubview:wheel];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
项目将毫无问题地构建,但会在运行时留下黑屏并给出无法识别的选择器错误。
还有什么我需要改变的吗?
感谢您的帮助。
【问题讨论】:
标签: ios objective-c unrecognized-selector