我用navigationController从一个view跳到另外一个viewnavigationController代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
_detailController = [[WBDetailContentController alloc]init];
[self.navigationController pushViewController:_detailController animated:YES];
[_detailController release];
}跳转之后的viewDidLoad函数代码:
- (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];
}跳转之后没一个按钮出现。求解!谢谢!!!
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
_detailController = [[WBDetailContentController alloc]init];
[self.navigationController pushViewController:_detailController animated:YES];
[_detailController release];
}跳转之后的viewDidLoad函数代码:
- (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 addSubview:v];其他按钮加到v上
[v addSubview: _buttonComment];
...另外下面这句没用,同一个按钮不能同时加入两个view中
[self.navigationController.view addSubview:_buttonForword];
_buttonMore.titleLabel.text = @"More";
这种写法是不对的。 UIButton 设置图片和标题是要跟状态对应的,看看文档就知道了。把按钮的背景图换一下就显示出来了……