2009-12-29 106 views

回答

0

您设置UIToolBar的框架或中心。这不是它的定位。可以这样做: [myToolBar setFrame: CGRectMake(x, y, width, height)];
//OR
[myToolBar setCenter: CGPointMake(x, y)];

如果UIToolBoor在IB中自动对齐,这是因为IB编程可以帮助您定位东西。

〜Natanavra。

0
  • (无效)viewWillAppear中:(BOOL)动画 { [超级viewWillAppear中:动画];工具栏 toolbar = [[UIToolbar alloc] init]; toolbar.barStyle = UIBarStyleDefault;

    //设置工具栏以适应应用的宽度。 [toolbar sizeToFit];

    // Caclulate工具栏的高度 CGFloat toolbarHeight = [工具栏框架] .size.height;

    //获取父视图的边界 CGRect rootViewBounds = self.parentViewController.view.bounds;

    //获取父视图的高度。 CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);

    //获取父视图的宽度, CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);

    //为工具栏创建一个矩形 CGRect rectArea = CGRectMake(0,rootViewHeight - toolbarHeight,rootViewWidth,toolbarHeight);

    //重新定位并调整接收器大小 [toolbar setFrame:rectArea];

    //创建一个按钮 的UIBarButtonItem * infoButton = [[的UIBarButtonItem页头] initWithTitle:@ “后面” 样式:UIBarButtonItemStyleBordered目标:自我行动:@选择(info_clicked :)]。

    [toolbar setItems:[NSArray arrayWithObjects:infoButton,nil]];

    //将工具栏作为子视图添加到导航控制器。 [self.navigationController.view addSubview:toolbar];

[[self tableView] reloadData];

}

  • (无效)info_clicked:(ID)发送方{

    [自我。navigationController popViewControllerAnimated:YES]; [toolbar removeFromSuperview];

    }