UICustomActionSheet 不调用委托方法来处理事件
UICustomActionSheet not calling delegate method to handle events
我在我的代码中使用 this 示例。它现在工作得很好,但是当我点击一个按钮时,它没有响应或调用任何方法。这是我的代码:
UICustomActionSheet* customActionSheet = [[UICustomActionSheet alloc] initWithTitle:nil delegate:nil buttonTitles:@[@"Cancel",@"Delete picture", @"Take a new photo", @"Choose from existing"]];
[customActionSheet setButtonColors:@[[UIColor redColor]]];
[customActionSheet setBackgroundColor:[UIColor clearColor]];
[customActionSheet setSubtitle:@"Select your Choice"];
[customActionSheet setSubtitleColor:[UIColor whiteColor]];
[customActionSheet showInView:self.view];
这里是需要调用的方法
-(void)customActionSheet:(UICustomActionSheet *)customActionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%d",buttonIndex);
}
问题出在您的代表。您已设置 nil
。设置为self
,你的问题就迎刃而解了。
我在我的代码中使用 this 示例。它现在工作得很好,但是当我点击一个按钮时,它没有响应或调用任何方法。这是我的代码:
UICustomActionSheet* customActionSheet = [[UICustomActionSheet alloc] initWithTitle:nil delegate:nil buttonTitles:@[@"Cancel",@"Delete picture", @"Take a new photo", @"Choose from existing"]];
[customActionSheet setButtonColors:@[[UIColor redColor]]];
[customActionSheet setBackgroundColor:[UIColor clearColor]];
[customActionSheet setSubtitle:@"Select your Choice"];
[customActionSheet setSubtitleColor:[UIColor whiteColor]];
[customActionSheet showInView:self.view];
这里是需要调用的方法
-(void)customActionSheet:(UICustomActionSheet *)customActionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%d",buttonIndex);
}
问题出在您的代表。您已设置 nil
。设置为self
,你的问题就迎刃而解了。