我在iOS開發方面很新,而且在我的GUI中隱藏/顯示按鈕時遇到了一些麻煩。因爲我需要一些按鈕才能出現或消失,並被啓用或禁用。我在網絡上跟着一些很棒的教程,但無法弄清楚我的代碼出了什麼問題。隱藏/顯示並啓用/禁用按鈕?
這裏是我的ViewController.h:
/
// ViewController.h
// WeddingVideoBooth
//
// Created by Frédéric Mouza on 15/07/13.
// Copyright (c) 2013 Frédéric Mouza. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
IBOutlet UIButton *but_record;
}
@property (nonatomic,retain) IBOutlet UIButton *but_record;
- (IBAction)but_record:(UIButton *)sender;
@end
和我的.m文件:
//
// ViewController.m
// WeddingVideoBooth
//
// Created by Frédéric Mouza on 15/07/13.
// Copyright (c) 2013 Frédéric Mouza. All rights reserved.
//
#import "ViewController.h"
#import "MobileCoreServices/UTCoreTypes.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize but_record;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
but_record.hidden=YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)but_record:(UIButton *)sender {
but_record.enabled=NO;
}
@end
這是非常簡單的,並且明白,我只是想上的按鈕禁用當你點擊在它上面......目前,點擊它時按鈕保持不變。我也嘗試使用屬性「but_record.hidden=YES
」隱藏它,但沒有任何工作。
請問有人有想法嗎?
再次感謝
檢查是否連接IBAction爲在IB –