我一直在寻找我的问题的答案。你看我有一个 UIActionSheet 并且当用户尝试按下他们不应该按下的按钮时我将其关闭:它工作得很好,但我试图触发 UIAlert 让用户知道当前操作已经停止,他们需要按“继续”...我的问题出在我的 - (void) actionSheet .... actionSheet 未调用该方法或 buttonIndex 设置不正确。
。H
#import <UIKit/UIKit.h>
@interface DVRRemote : UIViewController <UIActionSheetDelegate>
@property (nonatomic) BOOL pwrOff;
@property (nonatomic) BOOL dvrState;
@property (nonatomic) BOOL playState;
@property (nonatomic) BOOL rcdState;
@property (nonatomic) BOOL rcdPlay;
@property (strong, nonatomic) IBOutlet UISwitch *pwrSwitch;
@property (strong, nonatomic) IBOutlet UITextField *dvrStateLbl;
@property (strong, nonatomic) IBOutlet UITextField *PwrLbl;
- (IBAction)buttonPressed:(UIButton *)sender;
- (IBAction)pwrPressed:(UISwitch *)sender;
@end
这是代码UIActionSheet
,UIAlertView
请帮助。这项工作已经逾期两周了。
.m
-(IBAction)buttonPressed:(UIButton*)sender
{
if (_pwrOff == NO)
{
if (_rcdPlay == NO)
{
if ([sender.currentTitle isEqual: @"Play"])
{
_dvrStateLbl.text = @"Playing";
_playState = YES;
_rcdState = NO;
}
}
else
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Play not Allowed during Record" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Continue" otherButtonTitles:nil];
[actionSheet showInView: self.view];
}
}
}
-(void)actionSheet:(UIActionSheet*)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex != [actionSheet cancelButtonIndex])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Playing" message:[NSString stringWithFormat:@"Recording stopped"] delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
}
}
请注意:我已将警报编码为每个buttonIndex == 0, == 1, == 2
...它不想显示。
非常感谢可以提供帮助的人!问候,