- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBar开发者_运维知识库ButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)] autorelease];
}
-(IBAction) add :(id)sender {
}
in view textfield not find the trick is when I click the add textfiled appears in view
You could create the textfield ahead of time add it to your view and set the hidden property to YES and in add you just make it visible by setting hidden to NO.
- (void)loadView
{
UIView * newView = [[UIView alloc] init];
// retaining property
self.myTextField = [[[UITextField alloc] init] autorelease];
myTextField.hidden = YES;
[newView addSubview:myTextField];
self.view = newView;
[newView release];
}
- (IBAction)add:(id)sender
{
myTextField.hidden = NO;
}
Adding a new UITextField every time add is called
- (IBAction)add:(id)sender
{
UITextField * textfieldToAdd = [[[UITextField alloc] init] autorelease];
// ... configuration code for textfield ...
[self.view addSubview:textfieldToAdd];
}
精彩评论