我是iOS新手,我想在我的视图控制器上添加一个导航栏,左边有2个按钮,右边是订阅.我不知道如何做到这一点.现在我刚刚从界面构建器添加了一个导航栏,在.h文件中为它创建了一个(强)refrnce并进行了编码.
navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 1026, 50)];
[navBar setTintColor:[UIColor clearColor]];
[navBar setBackgroundColor:[UIColor redColor]];
[navBar setDelegate:self];
[self.view addSubview:navBar];
UIBarButtonItem *bi1 = [[UIBarButtonItem alloc] initWithTitle:@"subscribe" style:UIBarButtonItemStyleBordered target:self action:@selector(editBotton)];
bi1.style = UIBarButtonItemStyleBordered;
bi1.tintColor =[UIColor colorWithWhite:0.305f alpha:0.0f];
self.navigationItem.rightBarButtonItem = bi1;
Run Code Online (Sandbox Code Playgroud)
但没有发生..请帮助
我有两个ViewController:
1)ViewController
2)TestAppViewController
在ViewController.h,我定义了一个标签,我希望从第二个viewController发送其文本,即`TestAppViewController.
为此,我@property NSString *在ViewController.h中定义了一个,并在我的第二个Controller中创建了一个ViewController的对象.然后将值传递给此属性,但ans仍然是零.
以下是我的代码:
@property (nonatomic, retain) NSString *lableName;*
Run Code Online (Sandbox Code Playgroud)
视图控制器
#import "ViewController.h
#import "TestAppView1.h"
#import "TestAppViewController2.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// [self addView1];
}
- (void)viewWillAppear:(BOOL)animated
{
[self addView1];
NSLog(@"Label name is %@",self.lableName);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can …Run Code Online (Sandbox Code Playgroud)