【发布时间】:2011-06-21 08:13:24
【问题描述】:
大家好 我正在 ViewDidLoad 中编写一个简单的代码,类是 UITableViewController 的子类,如下所示,但按钮不可见,而标题可见,
另一件事是我点击了ViewDidLoad方法ViewController.m中的一个按钮,它调用了一个方法,该方法的代码如下
//Code of button target method
-(void)statusMethod {
NSLog(@"statusMethod");
Status *ob=[[Status alloc]init];
[self presentModalViewController:ob animated:YES];
}
//Code of ViewDidLoad of Status.m
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, width, 43)];
navBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:navBar];
[navBar release];
UIBarButtonItem *home = [[UIBarButtonItem alloc] initWithTitle:@"HOME" style:UIBarButtonItemStylePlain target:self action:@selector(homeMethod)];
self.navigationItem.rightBarButtonItem = home;
UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonSystemItemAdd target:self action:@selector(addMethod)];
self.navigationItem.leftBarButtonItem = add;
UILabel *label = [[UILabel alloc] initWithFrame:
CGRectMake(10,10,width-20,25)];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
label.text = @"Status";
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont systemFontOfSize:25];
label.textAlignment = UITextAlignmentCenter;
[navBar addSubview:label];
[label release];
任何想法,代码中的问题是什么? 不懂的可以再问我 如果我能解决我的问题,我会表扬
【问题讨论】:
-
您是使用导航控制器推送此视图还是显示为模态视图?
-
@Benwong 我正在制作简单的导航栏,只是在其左右添加按钮,但没有效果,但导航栏上的标签可以
标签: iphone uinavigationcontroller uibarbuttonitem