2014-10-27 9 views

Odpowiedz

12

Prawdopodobnie ładujesz swój UIImage z tą metodą:

UIImage *image = [UIImage imageNamed:@"image"]; 

To nie działa w interfejsie konstruktora bo imageNamed: metoda wykorzystuje wiązkę główną, ale IB ładunki zasoby w inny sposób. Wypróbuj coś takiego:

- (void)prepareForInterfaceBuilder 
{ 
    UIImage *image = [UIImage imageNamed:@"image" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil]; 
    [self setImage:image forState:UIControlStateNormal]; 
} 
1

Podjęcie szybkiej odpowiedzi dla każdego, kto napotka na ten problem, tak jak ja.

Problem polega na tym, że ścieżki do obrazów są inne w Konstruktorze interfejsów niż w Twojej aplikacji.

let bundle = Bundle(for: self.classForCoder) 
image = UIImage(named: "your_image.png", in: bundle, compatibleWith: self.traitCollection)! 
self.setImage(image, for: .normal) 
Powiązane problemy