我正试图学习如何在不使用预设方法的情况下更改对象的属性。这个例子只是一个例子。我知道有这种alertControllerWithTitle...
重建方法,但我想直接与财产。Objective-C:以编程方式更改@property(不包含预先构建的方法)
- (IBAction)clickedButton:(id)sender {
UIAlertController * view= [UIAlertController
alertControllerWithTitle:@"My Title"
message:@"Select you Choice"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//Do some thing here
[view dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[view dismissViewControllerAnimated:YES completion:nil];
}];
[view addAction:ok];
[view addAction:cancel];
[self presentViewController:view animated:YES completion:nil];
}
我想更新标题@property (nullable, nonatomic, copy) NSString *title;
我该怎么做?
既然告诉你简单地调用'view.title = @“New Title”;'看起来太明显了,你需要澄清你的问题。这里你不明白的是什么? – rmaddy