iOS开发中的关键技术与实践
1. UIAlertView与委托处理
在iOS开发里, UIAlertView 是常用的提示框组件。若提示框有多个按钮,要知晓哪个按钮被点击,就需处理 UIAlertViewDelegate 协议里定义的方法。以下是具体操作步骤:
1. 创建委托类 :
//---SomeClass.m---
@implementation SomeClass
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog([NSString stringWithFormat:@"%d", buttonIndex]);
}
@end
- 设置委托 :
SomeClass *myDelegate = [[SomeClass alloc] init];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Hello"
message:@"This is an alert view"
超级会员免费看
订阅专栏 解锁全文
714

被折叠的 条评论
为什么被折叠?



