Rubymotion 앱을 쓰고 있는데 TabBar를 맞춤 설정하고 싶습니다. NSScreencasts.com에서 Objective-C로 어떻게 수행하는지 설명하지만 아래 코드를 어떻게 Ruby로 변환 할 수 있습니까? 사용자 정의 배경 이미지를 tabbar로 설정하는 방법은 무엇입니까?
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self customize];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self customize];
}
return self;
}
- (void)customize {
UIImage *tabbarBg = [UIImage imageNamed:@"tabbar-background.png"];
UIImage *tabBarSelected = [UIImage imageNamed:@"tabbar-background-pressed.png"];
[self setBackgroundImage:tabbarBg];
[self setSelectionIndicatorImage:tabBarSelected];
}
@end
이
내 시도 :class CustomTabbar < UITabBarController
def init
super
customize
self
end
def customize
tabbarBg = UIImage.imageNamed('tabbar.jpeg')
self.setBackgroundImage = tabbarBg
end
end
하지만 그것을 실행하는 경우이 오류가 얻을 :
Terminating app due to uncaught exception 'NoMethodError', reason: 'custom_tabbar.rb:5:in `init': undefined method `setBackgroundImage=' for #<CustomTabbar:0x8e31a70> (NoMethodError)
UPDATE를
*이 내 app_delete 파일 : *
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
first_controller = FirstController.alloc.init
second_controller = SecondController.alloc.init
tabbar_controller = CustomTabbar.alloc.init
tabbar_controller.viewControllers = [first_controller, second_controller]
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.rootViewController = tabbar_controller
@window.makeKeyAndVisible
true
end
end
'self.backgroundImage = tabbarBg' 또는'self.setBackgroundImage (tabbarBg)'중 하나를 시도해 보셨습니까? – kuba
예, 둘 다 실패합니다. –
또한'UITabBarController' (컨트롤러)라는 서브 클래스에있는 문제를 보았습니다. 대신 UITabBar (UIView) 서브 클래스를 만들어야합니다. – kuba