【问题标题】:RubyMotion Error When Using setTranslucent使用 setTranslucent 时出现 RubyMotion 错误
【发布时间】:2013-06-30 21:20:08
【问题描述】:

我在尝试 rake 正在处理的项目时遇到以下错误,我不知道为什么。无论我发送什么变量,消息都会发生。

Objective-C stub for message `setTranslucent:' type `v@:c' not precompiled. Make sure you properly link with the framework or library that defines this message

这是我的 app_delegate 文件供参考。

class AppDelegate

def application(application, didFinishLaunchingWithOptions:launchOptions)
     navigation_appearance
     @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
     tableView = StopsController.alloc.init 
     @window.rootViewController = UINavigationController.alloc.initWithRootViewController(tableView)
     @window.makeKeyAndVisible
     true
end


def navigation_appearance
    UINavigationBar.appearance.setBackgroundImage UIImage.imageNamed('navbar_bg.png'),
    forBarMetrics: UIBarMetricsDefault
    UINavigationBar.appearance.setTranslucent(true)
    UINavigationBar.appearance.setShadowImage UIImage.imageNamed('navbar_shadow.png')   
end

end

【问题讨论】:

    标签: ios uinavigationbar rubymotion


    【解决方案1】:

    看起来您没有在 UINavigationBar 的实例上设置属性 -

    class AppDelegate
    
    def application(application, didFinishLaunchingWithOptions:launchOptions)
         @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
         tableView = StopsController.alloc.init 
         @navigationController = UINavigationController.alloc.initWithRootViewController(tableView)
         @window.rootViewController = @navigationController
         navigation_appearance
         @window.makeKeyAndVisible
         true
    end
    
    
    def navigation_appearance
        @navigationController.navigationBar.setBackgroundImage UIImage.imageNamed('navbar_bg.png'),
        forBarMetrics: UIBarMetricsDefault
        @navigationController.navigationBar.setTranslucent(true)
        @navigationController.navigationBar.setShadowImage UIImage.imageNamed('navbar_shadow.png')   
    end
    
    end
    

    应该可以!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-12
      • 1970-01-01
      • 2021-06-18
      相关资源
      最近更新 更多