开发者

how we create textField in clicking UIBarButton "add"

- (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];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜