专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Iphone

Add subView 后subView不显示也不出错,求解,该怎么处理

发布时间:2010-05-30 01:27:10 文章来源:www.iduyao.cn 采编人员:星星草
Add subView 后subView不显示也不出错,求解
我用navigationController从一个view跳到另外一个view

navigationController代码:
C/C++ code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    _detailController = [[WBDetailContentController alloc]init];
     [self.navigationController pushViewController:_detailController animated:YES];
    
    [_detailController release];
}


跳转之后的viewDidLoad函数代码:
C/C++ code
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"test";

    UIView *v = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]autorelease];
//    UIView *v2 = [[[UIView alloc]initWithFrame:CGRectMake(1, 1, 10, 10)]autorelease];
    
    self.view = v;
    self.view.autoresizesSubviews = YES;
    [v release];
    
    _buttonForword = [[UIButton alloc]initWithFrame:CGRectMake(40, 150, 20, 10)];
    _buttonComment = [[UIButton alloc]initWithFrame:CGRectMake(70, 150, 20, 10)];
    _buttonMore = [[UIButton alloc]initWithFrame:CGRectMake(100, 150, 20, 10)];
    
    _buttonMore.titleLabel.text = @"More";
    _buttonComment.titleLabel.text = @"Comment";
    _buttonForword.titleLabel.text = @"Forword";
    
    [self.navigationController.view addSubview:_buttonForword];
    
    [self.view addSubview:_buttonComment];
    [self.view addSubview:_buttonForword];
    [self.view addSubview:_buttonMore];
    
    [_buttonForword release];
    [_buttonComment release];
    [_buttonMore release];
}


跳转之后没一个按钮出现。求解!

谢谢!!!

------解决方案--------------------
self.view = v;
改为[self.view addSubview:v];

其他按钮加到v上
[v addSubview: _buttonComment];
...

另外下面这句没用,同一个按钮不能同时加入两个view中
[self.navigationController.view addSubview:_buttonForword];
------解决方案--------------------
非也……

显示出来了,只是你看不到而已。
 _buttonMore.titleLabel.text = @"More";
 
这种写法是不对的。 

UIButton 设置图片和标题是要跟状态对应的,看看文档就知道了。

把按钮的背景图换一下就显示出来了……
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: