开发者

My Item in UIToolbar can not response userInteraction fully?

开发者 https://www.devze.com 2023-02-22 02:07 出处:网络
UIToolBar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 1024, 44)]; toolBar.barStyle = UIBarStyleBlack;
    UIToolBar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 1024, 44)];
    toolBar.barStyle = UIBarStyleBlack;
    [self.view addSubview:toolBar];
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"testText                      " style:0 target:nil action:nil];
    UIBarButtonItem *barButtonDateItem = [[UIBarButtonItem alloc] initWithTitle:@"  _________  " style:1 target:self action:@selector(dateButtonSelected)];
    UIBarButtonItem *barButtonItem2 = [[UIBarButtonItem alloc] initWithTitle:@"                         " style:0 target:nil action:nil];
    UISearchBar *se开发者_Python百科archBar1 = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 280, 100)];
    UIBarButtonItem *barButtonSearchItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:0 target:nil action:nil];
    barButtonSearchItem.customView = searchBar1;
    barButtonSearchItem.width = 280;
    NSArray *array = [[NSArray alloc] initWithObjects:barButtonItem,barButtonDateItem,barButtonItem2,barButtonSearchItem,nil];

    [barButtonItem release];
    [barButtonDataItem release];
    [barButtonItem2 release];
    [searchBar1 release];   
    [barButtonSearchItem release];

    toolBar.items = array;

    [array release];

When I click the barButtonDataItem or barButtonSearchItem, just a little part up of the item can response my click action;Bottom half didn't. How can I do

Thanks!


If your view contains a tabBarController the you have to add toolbar in tabBarController.view instead od self.view and if no tabBarController check some view is overlapping your toolbar which is not visible.

0

精彩评论

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

关注公众号