能否在今日小部件中添加类似于UIAlertView的东西?我在小部件中添加了一个IBAction和UIAlertView,但是没有任何反应。
还有,是否可以制作更大的小部件?我在Size-Inspector中更改了高度,但完全没有任何效果。
能否在今日小部件中添加类似于UIAlertView的东西?我在小部件中添加了一个IBAction和UIAlertView,但是没有任何反应。
还有,是否可以制作更大的小部件?我在Size-Inspector中更改了高度,但完全没有任何效果。
以下是一些基本的 Swift 代码(适用于未来的项目):
let alertController = UIAlertController(title: "title", message: "message", preferredStyle: .Alert)
self.presentViewController(alertController, animated: true, completion: nil)
在iOS8上,您需要使用UIAlertController
,参考链接在这里。
例如:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"AlertView" message:@"I am an AlertView" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
UIAlertView
和UIActionSheet
已被弃用,您现在需要使用UIAlertController
。 - Popeye