Как я могу добавить UIToolbar в мой UITableViewController? - PullRequest
0 голосов
/ 19 июля 2011

У меня есть UITableViewController. Я хотел бы отобразить UIToolbar внизу, но не уверен, как я могу это сделать, так как IB не позволяет мне добавить его.

1 Ответ

0 голосов
/ 19 июля 2011

Просто попробуйте:

В файле .h:

UIToolbar* toolbar;

В файле .m

UIBarButtonItem *actionButton  = [[UIBarButtonItem  alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(doAction)];
    toolbar           = [UIToolbar new];
    toolbar.barStyle  = UIBarStyleDefault;

    [toolbar sizeToFit];
    CGFloat toolbarHeight = [toolbar frame].size.height;
    CGRect mainViewBounds = appDel.window.bounds;
    [toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds),
                                 438,
                                 CGRectGetWidth(mainViewBounds),
                                 toolbarHeight)];       

    [[[UIApplication sharedApplication] keyWindow] addSubview:toolbar];
...