首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

UIButton无法显示title解决思路

2013-01-25 
UIButton无法显示titlebtn1[UIButton buttonWithType:UIButtonTypeRoundedRect][btn1 setTitle:@OK fo

UIButton无法显示title



    btn1=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn1 setTitle:@"OK" forState:UIControlStateNormal];
    [btn1 setFrame:CGRectMake(10, 10, 100, 50)];
    [self.view addSubview:btn1];
    [btn1 release];



这是源码,为什么运行后,Button的title没法显示呢?
[解决办法]
去掉[btn1 release];
[解决办法]

只有init的UIButton才需要release。
[解决办法]
你没有给button alloc内存啊,release以后button就没有了。

热点排行