代码粘的多了点,看着清楚一点
SetupAccountViewController.h文件,声明m_comBoxView,线程不安全,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调用赋值,这个时候引用技术才会+1
m_comBoxView.backgroundColor = [UIColor clearColor];改成
self.m_comBoxView.backgroundColor = [UIColor clearColor];作用相同,也不会影响引用计数,因为这里是调用属性。
下面这个还没有遇到过,但是有朋友说,所以记录一下!大家都注意
myImage = [UIImage imageNamed:@"icon.png"];
这种方法在application bundle的顶层文件夹寻找由供应的名字的图象 。 如果找到图片,装载到iPhone系统缓存图象。那意味图片是(理论上)放在内存里作为cache的。
所以使用小图或者少量图是可以的,大量图则该选用
NSString *path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png"];
myImage = [UIImage imageWithContentsOfFile:path];
不过这种方法要注意了,如果有高清图,也就是@2x的,就不能自动获取到了,自己把握吧,做ui可以用imageNamed,要处理的大图就别这样加载了
分享到:
相关推荐
[self setClockBackgroundImage:[UIImage imageNamed:@"xxx"].CGImage]; [self setSecHandImage:[UIImage imageNamed:@"xxx"].CGImage]; [self setMinHandImage:[UIImage imageNamed:@"xxx"].CGImage]; [self ...
CatZanButton *zanBtn=[[CatZanButton alloc] initWithFrame:CGRectMake(0, 0, 50, 50) zanImage:[UIImage imageNamed:@"Zan"] unZanImage:[UIImage imageNamed:@"UnZan"]]; [zanBtn setCenter:self.view.center]; ...
UIImage *thumbImage = [UIImage imageNamed:@"res1thumb.png"]; [WXApiResponseHandler respImageData:imageData MessageExt:nil Action:nil ThumbImage:thumbImage]; [self ...
imageview上面加长按及滑动手势来重置imageView的位置 ..._imagesUrlArr=[@[@"http://chenggua.com/imagesUrl/20151204/201512042214246086.png",[UIImage imageNamed:@"22.jpg"],[UIImage imageNamed:@"33.jpg"],@...
UIImage *imageWatermarkedImage = [originalImage imageWithImageWatermark:[UIImage imageNamed:@"logo"] offset:CGPointMake(originalImage.size.width - 50, originalImage.size.height - 50)]; ``` 4. **...
imageView.image = [UIImage imageNamed:@"twitter background.png"]; [self.view addSubview:imageView]; //Twitter style splash SKSplashIcon *twitterSplashIcon = [[SKSplashIcon alloc] initWithImage:...
XTYRandomKeyboard *keyBoad = [[XTYRandomKeyboard alloc] initWithTitleColor:[UIColor blackColor] backGroundImage:[UIImage imageNamed:@"bg.jpg"]]; [keyBoad setInputView:textField]; [self.view ...
UIImage *im1=[UIImage imageNamed:@"1.jpg"]; UIImage *im2=[UIImage imageNamed:@"2.jpg"]; UIImage *im3=[UIImage imageNamed:@"3.jpg"]; BannerLoopView *loopView = [[BannerLoopView alloc]initWithFrame:...
NSArray *imageList = @[[UIImage imageNamed:@"menuChat.png"], [UIImage imageNamed:@"menuUsers.png"], [UIImage imageNamed:@"menuMap.png"], [UIImage imageNamed:@"menuClose.png"]]; sideBar = [...
// 1.创建按钮 UIButton *btn = [[UIButton alloc] init];... UIImage *normal = [UIImage imageNamed:@"btn_01"]; // 4.2设置普通状态下的背景图片 [btn setBackgroundImage:normal forState:UIControlStateNormal];
att_str = [SHAttributedString attributedEmailStringWithString:att_str insertImage:[UIImage imageNamed:@"compose_emoticonbutton_background_highlighted@2x"] orEmailNameString:@"邮箱"]; //计算size ...
[button setImage:[UIImage imageNamed:@"1"] forState:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"2"] forState:UIControlStateHighlighted]; [button addTarget:self action:@selector...
vc1.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"页面1" image:[UIImage imageNamed:@"tabBarItem1"] selectedImage:[UIImage imageNamed:@"tabBarItem1_selected"]]; vc2.tabBarItem = [[UITabBarItem ...
image:[UIImage imageNamed:@"action_icon"] target:self action:@selector(feedBack:)], UIButton * btn = sender; [KxMenu showMenuInView:self.view fromRect:btn.frame menuItems:menuItems]; } - (void)...
[UIImage imageNamed:@"myImage1.png"], [UIImage imageNamed:@"myImage2.png"], [UIImage imageNamed:@"myImage3.png"], [UIImage imageNamed:@"myImage4.gif"], nil]; UIImageView *myAnimatedImageView = [...
4.在pch文件里增加宏定义: 文字 KLOCALIZED_String(STR) [[InternationalControl bundle] localizedStringForKey:STR value:nil table:@"Localizable"] 图片 KLOCALIZED_UIImageName(NAME) [UIImage imageNamed:[...
UIImage *image1 = [UIImage imageNamed:@"main-library-button"]; NSArray *images = @[image0, image1]; 用图像初始化这个控件 PicsLikeControl *picControl = [[PicsLikeControl alloc] initWithFrame:...
CricleScrollerView 概述 基于ScrollerView进行封装的控件,...UIImageView *imageView1 = [[UIImageView alloc ] initWithImage: [UIImage imageNamed: @" image1 " ]]; imageView1.frame = CGRectMake( 0 , 0 , self
DFT的matlab源代码 opencvLib 包含opencv的静态库 OpenCVLibz.framework是真机release、 OpenCVLibm.framework是模拟器release、 OpenCVLib.framework是合并真机和模拟器release ...imageNamed:image
imageView image [UIImage imageNamed:[NSString stringWithFormat:@"MQLADPlaceholderPic%d" i+1]]; [viewsArray addObject:imageView]; } self adView [[CycleADScrollView alloc] initWithFrame:...