我是新手...
我有一个基于 UITableView .h 文件的视图控制器
@interface OAFeaturesViewController : UITableViewController<PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate>
我可以创建/添加工具栏,但是当我使用它时它会附加到 tableView
[self.view addSubview:myToolBar];
如何获取对主窗口的引用,以便将其添加到它所属的主屏幕底部?
.m 文件
UIToolbar *myToolBar = [[UIToolbar alloc]init];
myToolBar.frame = CGRectMake(0,0,430, 44);
UIBarButtonItem *takePicButton = [[UIBarButtonItem alloc] initWithTitle:@"Take Pic" style:(UIBarButtonItemStyleBordered) target:self action:@selector(takePictureWithCamera)];
UIBarButtonItem *cancelPicButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:(UIBarButtonItemStyleBordered) target:self action:@selector(cancelPictureWithCamera)];
NSArray *items = [NSArray arrayWithObjects: takePicButton, cancelPicButton, nil];
[myToolBar setItems:items animated:NO];
[self.view addSubview:myToolBar];
UIImage *toolbarBkg = [[UIImage imageNamed: @"Navbar_background_solidblue.png"] stretchableImageWithLeftCapWidth:0 topCapHeight:0];
if ([myToolBar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)])
{
[myToolBar setBackgroundImage:toolbarBkg forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
NSLog(@"toolbar responds to selector");
}
else {
NSLog(@"toolbar does NOT respond to selector");
UIImageView *background = [[UIImageView alloc] initWithImage:toolbarBkg];
background.frame = myToolBar.frame;
[myToolBar insertSubview:background atIndex:0];
}
[self.view bringSubviewToFront:myToolBar];