我在添加行的表格視圖中有一個按鈕。最多五行後,我想停止添加用戶。目前,我會在按鈕按下5個按鍵後顯示提醒。如何在註冊的水龍頭後從工作中刪除或停止表格視圖中的按鈕
如何阻止用戶使用此按鈕?設置爲隱藏不會工作作爲一個自定義的子類,property hidden
未在類
- (void)viewDidLoad
{
[super viewDidLoad];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.shadowColor = [UIColor darkGrayColor];
titleLabel.text = self.distributionBoard.dbRef;
titleLabel.font = [UIFont boldSystemFontOfSize:15.0f];
[titleLabel sizeToFit];
self.navigationItem.titleView = titleLabel;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)];
// Add new appliance button to the table view's footer view
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(10.0f, 0, 300.0f, 100.0f)];
footerView.backgroundColor = [UIColor clearColor];
UIButton *newBoardButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
CGRect buttonFrame = newBoardButton.frame;
buttonFrame.origin.x = footerView.frame.size.width - buttonFrame.size.width;
newBoardButton.frame = buttonFrame;
[newBoardButton addTarget:self action:@selector(addCircuitButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[footerView addSubview:newBoardButton];
self.tableView.tableFooterView = footerView;
}
發現.....
////limit to five appliances
- (void)addCircuitButtonPressed:(id)sender {
LogCmd();
Circuit *circuit = [[ICCircuitManager manager] newCircuit];
circuit.distributionBoard = self.distributionBoard;
circuit.circuitReference = [NSString stringWithFormat:@"%d", [self.circuits count] + 1];
circuit.createdAt = [NSDate date];
circuit.modifiedAt = [NSDate date];
[self.distributionBoard addCircuitsObject:circuit];
[self loadData];
[self.tableView reloadData];
{
m_buttonTouchCount++;
if (m_buttonTouchCount == 4)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"iCertifi"
message:@"Maximum number of appliances reached"
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
// m_buttonTouchCount = 0; // reset to 0 here if required.
}
}
}
哪個是自定義子類? newBoardButton?看起來像你的代碼中的UIButton,並且應該隱藏屬性。 – iDev
是的,這就是我需要做的!我試圖隱藏錯誤的項目。 – JSA986