我试图让工具栏出现(有效),一旦出现我想点击完成按钮并关闭工具栏(不起作用)。我不知道该怎么做,我想通过删除pickerview它会起作用。我认为最大的问题是我的取消率方法没有被调用。
pickerView = [[UIView alloc]initWithFrame:CGRectMake(0, 300, 180, 260)];
rateToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
rateToolbar.barStyle = UIBarStyleBlackTranslucent;
rateToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelRate)],
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
nil];
[rateToolbar sizeToFit];
[pickerView addSubview:rateToolbar];
[self.view addSubview:pickerView];
-(void)cancelRate{
[pickerView removeFromSuperview];
}
答案 0 :(得分:0)
我就是这样做的。
//PUT THIS CODE ON THE VIEWDIDLOAD EVENT
UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(pressReloadButton)];
self.navigationItem.rightBarButtonItem = button2;
//THIS IS THE METHOD THAT IS CALLED
- (void)pressReloadButton{
self.spinner.hidden = NO;
[self.spinner startAnimating];
[self refresh];
}
希望它有所帮助.. GL HF