0
Я работаю над приложением tvOS & с использованием UISegmentedControl
. На didUpdateFocusInContext
я был следующий код, чтобы изменить образ UISegment как -Использование незаявленного типа UISegment swif tvOS
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator)
{
if let previousItem = context.previouslyFocusedView as! UISegment
{
if previousItem.selectedSegmentIndex == 0
{
previousItem.insertSegmentWithImage(UIImage(named: "white_save_star.png"), atIndex: previousItem.selectedSegmentIndex, animated: false)
}
else if previousItem.selectedSegmentIndex == 1
{
previousItem.insertSegmentWithImage(UIImage(named: "white_goto-arrow.png"), atIndex: previousItem.selectedSegmentIndex, animated: false)
}
}
if let nextItem = context.nextFocusedView as? UISegment
{
if nextItem.selectedSegmentIndex == 0
{
nextItem.insertSegmentWithImage(UIImage(named: "Blue_save_star.png"), atIndex: nextItem.selectedSegmentIndex, animated: false)
}
else if nextItem.selectedSegmentIndex == 1
{
nextItem.insertSegmentWithImage(UIImage(named: "Blue_goto-arrow.png"), atIndex: nextItem.selectedSegmentIndex, animated: false)
}
}
}
но получить следующее сообщение об ошибке use of undeclared type UISegment
при печати po context.previouslyFocusedView
result -
▿ Optional<UIView>
- Some : <UISegment: 0x7f861c87da10; frame = (0 0; 300 70); opaque = NO; layer = <CALayer: 0x7f861c87e180>>
, как вы можете видеть на выходе становится ясно, что UISegment
класс существует.
любая помощь будет оценена
И у вас есть 'импорта UIKit'? – Droppy
Да, у меня был импорт UIKit –
Вы нашли какой-либо публичный интерфейс для 'UISegment'? Насколько я могу судить, они всегда упоминаются как значения индекса внутри элемента управления. 'selectedSegmentIndex' - это метод' UISegmentedControl'. –