2012-04-11 110 views
1

我想将ILColorPicker移植到正在使用Storyboard的iPad应用程序。试图将ILColorPicker移植到iPad应用程序

我把UIView放在UIViewController中;在这个UIView中,我有3个其他的UIViews(在下面的灰色,包含UIView有一个黑色的背景,给它的边界)。 enter image description here

3个视图中的每一个都有与样本相匹配的连接。

这个连接的图像是顶部UIView。 enter image description here

这是中间的UIView的连接的图像 enter image description here

这是底部的UIView enter image description here

的连接的图像当我运行在模拟器中的应用程序,并点击这个控制器的菜单标签按钮,我什么也没有,只有黑屏。另外,我把NSLog放在“viewDidLoad”中,并且经过那里六(6)次!

我一直在为此工作了一个多星期,并已达到我的经验和知识可以帮助我的结局。有人能帮我弄清楚这里有什么问题吗?我真的很感激。 (如果需要的代码将被提供,只是不想在这里写一本书!):d

更新:代码 “的viewDidLoad”

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    NSLog(@"viewDidLoad"); 
    // Build a random color to show off setting he color on the iPad 
    UIColor *c = [UIColor colorWithRed:(arc4random()%100)/100.0f 
           green:(arc4random()%100)/100.0f 
           blue:(arc4random()%100)/100.0f 
           alpha:1.0]; 

    colorChip.backgroundColor = c; 
    colorPicker.color = c; 
    huePicker.color = c; 
} 

更新2:“didFinishLaunchingWithOptions代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 
    return YES; 
} 
+0

你的viewDidLoad中有什么? – hanleyhansen 2012-04-11 14:47:53

+0

问题可能出在您AppDelegate中的didFinishLaunchingWithOptions中。你也可以在这个问题上发布这个问题吗? – hanleyhansen 2012-04-11 15:00:28

回答

1

我不知道你的委托被设置为,但你应该将它们连接到控制器,而不是一个视图。随着中说你确定你的IBOutlets连接,我用断言检查。

从我skel'ed相似,你有什么东西一个单一的视图+视图控制器空白故事板项目,这是我的了:

// ViewController.h 
    @protocol MyPickerDelegate <NSObject> 
    - (void)myPickerDidPick:(id)sender; 
    - (void)myPickerPickColor:(id)sender color:(UIColor*)color; 
    @end 

    @interface ViewController : UIViewController<MyPickerDelegate> 
    @property (weak) IBOutlet __weak UIView *colorBar; 
    @property (weak) IBOutlet __weak UIView *saturationBrightnessPicker; 
    @property (weak) IBOutlet __weak UIView *huePicker; 
    @end 

// ViewController.m 
    @interface ViewController() { 
    __weak UIView *colorBar_; 
    __weak UIView *saturationBrightnessPicker_; 
    __weak UIView *huePicker_; 
    } 
    @end 

    @implementation ViewController 

    @synthesize colorBar = colorBar_; 
    @synthesize saturationBrightnessPicker = saturationBrightnessPicker_; 
    @synthesize huePicker = huePicker_; 

    - (void)viewDidLoad { 
    [super viewDidLoad]; 

    NSAssert(colorBar_, @"colorBar not connected"); 
    NSAssert(saturationBrightnessPicker_, @"saturationBrightnessPicker not connected"); 
    NSAssert(huePicker_, @"huePicker not connected"); 

    self.view.backgroundColor = [UIColor blackColor]; 
    colorBar_.backgroundColor = [UIColor redColor]; 
    saturationBrightnessPicker_.backgroundColor = [UIColor greenColor]; 
    huePicker_.backgroundColor = [UIColor blueColor]; 
    } 

    - (void)myPickerDidPick:(id)sender { 
    NSLog(@"Did pick"); 
    } 

    ... 

    @end 

希望这有助于!

+0

嗨马特..我很抱歉没有回复你以前...我试图让另一个应用程序准备好App Store。这已经完成了,所以我正在为这个“狗”再次努力!我创建了一个新的视图控制器(名为NewViewController),复制你的代码并设置场景的属性。这是我现在得到的错误: '[ setValue:forUndefinedKey:]:此类不是关键值colorChip的编码兼容性值。' 我不知道现在的问题是什么...... – SpokaneDude 2012-04-30 17:23:07

+0

确保你有一个名为colorChip的成员和财产(即:不是颜色或颜色_) – 2012-05-01 10:53:30

+0

谢谢马特......这个东西比我们两个都大!当我尝试重新设计应用程序时,我将不得不将它放在一边,所以我没有颜色选择器。我非常感谢你在这上面花费的时间。 – SpokaneDude 2012-05-02 22:21:40