self 인용 을 사용 할 때 1 을 추가 합 니 다.[UIImage imageNamed]사용

2428 단어 uiimage
코드 가 많이 붙 었 으 니 잘 보 세 요.
SetupAccountViewController.h 파일,성명 mcomBoxView,스 레 드 가 안전 하지 않 습 니 다.retain(self 호출 참조+1)

#import <UIKit/UIKit.h>
#import "ComBoxView.h"

@interface SetupAccountViewController : UIViewController
{
    ComBoxView *m_comBoxView;
}
@property (retain,nonatomic) ComBoxView *m_comBoxView;
@end


다음은 m 파일 을 보 겠 습 니 다.

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSMutableArray* array=[NSMutableArray arrayWithObjects:@"btn_img_listBox", @"btn_img_bolg_background", @"btn_img_listBox", @"btn_img_bolg_background", @"btn_img_listBox", @"btn_img_bolg_background", nil];

    //114 view ,150view tableview+btn  
    CGRect frame = CGRectMake(180, 46, 114, 150);


    //      alloc  ComBoxView ,    self.m_comBoxView     ,  alloc                ,    self.m_comBoxView     1,    +2+3   
    ComBoxView *comBoxView = [[ComBoxView alloc] initWithFrame:frame];
    comBoxView.m_downListDataSource = array;
    self.m_comBoxView = comBoxView;
    //tab     
    m_comBoxView.backgroundColor = [UIColor clearColor];
    [m_comBoxView setImgLeftMark:[array objectAtIndex:0]];
    [comBoxView release];
    
    
    self.title = kViewtitle;
    [self.view addSubview:m_comBoxView];
}

self.m_comBoxView = comBoxView;
이 한 마디 가 중요 하 다.즉,self 호출 할당 만 이 기술 을 인용 할 수 있다 는 것 이다.
m_comBoxView.backgroundColor = [UIColor clearColor];...로 바꾸다
self.m_comBoxView.backgroundColor = [UIColor clearColor];역할 이 같 고 인용 계수 에 도 영향 을 주지 않 습 니 다.여 기 는 호출 속성 이기 때 문 입 니 다.
다음은 아직 만난 적 이 없 는데 친구 가 말 했 으 니 기록 해 보 세 요!모두 주의 하 다
myImage = [UIImage imageNamed:@"icon.png"];
이 방법 은 애플 리 케 이 션 bundle 의 맨 위 폴 더 에서 공급 되 는 이름 의 그림 을 찾 습 니 다.그림 을 찾 으 면 아이 폰 시스템 캐 시 이미지 로 불 러 옵 니 다.그것 은 그림 이 메모리 에 cache 로 놓 여 있다 는 것 을 의미한다.
그래서 작은 그림 이나 소량의 그림 을 사용 하면 되 고 대량의 그림 은 선택해 야 한다.
NSString *path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png"];
myImage = [UIImage imageWithContentsOfFile:path];
그러나 이런 방법 은 주의해 야 합 니 다.만약 에 고 화질 그림,즉@2x 가 있 으 면 자동 으로 얻 을 수 없습니다.스스로 파악 하 세 요.ui 를 만 들 면 imageNamed 를 사용 할 수 있 습 니 다.처리 할 큰 그림 은 이렇게 불 러 오지 마 세 요.

좋은 웹페이지 즐겨찾기