xcode 6 IB_DESIGNABLE- not loading resources from bundle in Interface builder

前端 未结 6 1159
难免孤独
难免孤独 2020-12-02 17:12

I am trying to make a custom control that updates live in Interface Builder using the new IB_DESIGNABLE option described here.

- (void)drawRect:(CGRect)rect
         


        
6条回答
  •  心在旅途
    2020-12-02 17:51

    I also had the same problem : looking at this answer and following WWDC 2014 whats new in Interface Builder. I solved it like that:

    - (void)prepareForInterfaceBuilder{
         NSArray *array =    [[NSProcessInfo processInfo].environment[@"IB_PROJECT_SOURCE_DIRECTORIES"] componentsSeparatedByString:@":"];
         if (array.count > 0) {
             NSString *str = array[0];
             NSString *newStr =  [str stringByAppendingPathComponent:@"/MyImage.jpg"];
             image = [UIImage imageWithContentsOfFile:newStr]; 
         }
    }
    

提交回复
热议问题