【发布时间】:2014-07-28 10:41:31
【问题描述】:
我想在按下UIButton 时更改UILabel。我之前需要加载屏幕,但是如何在情节提要中做到这一点?现在代码是这样的:
此处的代码(.h 文件):
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *idLabel; // label to change
@property (strong, nonatomic) IBOutlet UIButton *addingButton; // clickOnButton
@end
和方法(.m文件):
- (IBAction)addingHasTaped:(id)sender {
NetworkConnection *request = [[NetworkConnection alloc]init];
[request getDataFromServer];
self.idLabel.text = @"hi!";
}
我使用故事板并将UILabel 和UIButton 拖放到代码中。但是这个方法不会改变UILabel。
怎么了?
【问题讨论】:
-
检查 UILabel 是否与 UILabel IBOutlet 连接。
-
检查 - (IBAction)addingHasTaped:(id)sender 作为按钮操作连接。
-
您要更改当前 viewController 中的同一个标签还是另一个 viewCONtroller 中的另一个标签?
-
为问题添加更多细节,以便相应地解释答案...
-
我想在一个视图控制器中更改它。
标签: ios objective-c uibutton storyboard uilabel