【发布时间】:2015-08-20 10:34:24
【问题描述】:
我在这样的方法中声明了一个 alertView。
UIAlertView* alertView =[[UIAlertView alloc]initWithTitle:@"Check In Alert" message:@"Are you sure he/she is there?" delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No", nil];
alertView.tag = sender;
[alertView show];
所以在 clickedButtonIndex 的 alertView 方法中我有这段代码。
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if([alertView.title isEqualToString:@"Check In Alert"])
{
ClassRoomParticipant *clsrp;
NSMutableArray *data = nil;
data=[self.presentDataArray objectAtIndex:0];
clsrp = (ClassRoomParticipant *)[data objectAtIndex:alertView.tag];
NSLog(@"Do Nothing");
if (buttonIndex == 0)
{
[clsrp setGetParcpntCheckInStatus : 2];// Checked in by Teacher
}
else if (buttonIndex == 1)
{
[clsrp setGetParcpntCheckInStatus : 3];// Not checked in by Teacher, still Absent
}
return;
}
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"OK"])
{
[self.navigationController popViewControllerAnimated:YES];
}
else if([title isEqualToString:@"Button 2"])
{
//NSLog(@"Button 2 was selected.");
}
else if([title isEqualToString:@"Button 3"])
{
//NSLog(@"Button 3 was selected.");
}
}
我有这样的方法。
-(void)changeStudentAction:(id)sender
{
CustomUIButton *button=sender;
NSInteger flag = 0;
if (button.selected)
{
[button setSelected:NO];
[button setBackgroundImage:[UIImage imageNamed:@"Absent_on_coloured.png"] forState:UIControlStateNormal];
flag=0;
}
else
{
[button setSelected:YES];
[button setBackgroundImage:[UIImage imageNamed:@"Present_on_coloured.png"] forState:UIControlStateNormal];
flag=1;
}
if (button.collectionIdentifier == ClsRmPrctPresntCollectionView)
{
[self ModifyDataArray:button.taggy flag:flag identifier:ClsRmPrctPresntCollectionView change:@"Button" toDate:nil section:button.section];
[self modifyCollectionArray:PRESENT processingData:self.presentDataArray identifier:ClsRmPrctPresntCollectionView index:button.taggy section:button.section];
}
self.isAnyChangesHappened=YES;
}
我想在 alertView 按钮中调用这个 changeStudentAction 方法,单击“是”。当我在 buttonIndex==0 中调用这个方法时,它给了我错误。能否请您告诉我如何在警报视图中调用此方法。
【问题讨论】: