使用UITableViewCell中的按钮进入考勤模块。此按钮在条件下使用3个不同的图像。如果学生家长显示绿色图像,如果没有显示灰色图像,如果撤回主题,则显示红色图像。
除了退学生,老师可以标记出勤。但问题是,当我向下滚动然后向上滚动时,它的图像会随机变化。
检查附加图像。显示所有的第一个屏幕是父母。但是当没有改变任何出席时我向下滚动然后向上然后按钮图像被更改。
image1 =所有都是父
image2 =向下滚动
image3 =向上滚动
获取单元格的代码:
/// <summary>
/// Called by the TableView to get the actual UITableViewCell to render for the particular row
/// </summary>
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
string cellIndentifier = "studentIndentifier";
// request a recycled cell to save memory
ipadStudentAttendanceTableViewCell cell = (ipadStudentAttendanceTableViewCell)tableView.DequeueReusableCell(cellIndentifier);
// if there are no cells to reuse, create a new one
//if (cell == null)
// cell = new UITableViewCell(UITableViewCellStyle.Default, cellIndentifier) as ipadStudentAttendanceTableViewCell;
if (cell != null)
{
cell.UpdateCell(tableItems[indexPath.Row].Heading
, tableItems[indexPath.Row].Flags
, tableItems[indexPath.Row].id
, tableItems[indexPath.Row].lbl1);
}
return cell;
}
public void UpdateCell(string Student, bool IsAttendance, string StudentID, string Registration)
{
//uiSwitch.
lblStudent.Text = Student;
lblID.Text = StudentID;
lblRegistered.Text = Registration;
var item = AttributeItems.studentAttendanceInfo.Find(f => f.StudentID == StudentID);
lblStudent.TextColor = AttributeItems.TextColorSubHeading;
lblID.TextColor = AttributeItems.TextColorHeading;
// Show attendance percentage
switch (item.AttendanceStatusID)
{
case 0:
if (item.IsParent)
btnSwitch.SetBackgroundImage(AttributeItems.ImageOnSwitch, UIControlState.Normal);
else
btnSwitch.SetBackgroundImage(AttributeItems.ImageOffSwitch, UIControlState.Normal);
lblPercentage.TextColor = AttributeItems.PercentagePositiveColor;
lblPercentage.Text = item.AttendanceStatus + " " + item.Percentage.ToString("#.##") + "%";
break;
case 1:
if (item.IsParent)
btnSwitch.SetBackgroundImage(AttributeItems.ImageFailerSwitch, UIControlState.Normal);
else
btnSwitch.SetBackgroundImage(AttributeItems.ImageOffSwitch, UIControlState.Normal);
lblPercentage.TextColor = AttributeItems.TextColorWarning;
lblPercentage.Text = item.AttendanceStatus + " " + item.Percentage.ToString("#.##") + "%";
break;
case 2:
if (item.IsParent)
btnSwitch.SetBackgroundImage(AttributeItems.ImageFailerSwitch, UIControlState.Normal);
else
btnSwitch.SetBackgroundImage(AttributeItems.ImageOffSwitch, UIControlState.Normal);
lblPercentage.TextColor = AttributeItems.TextColorFailureWarning;
lblPercentage.Text = item.AttendanceStatus + " " + item.Percentage.ToString("#.##") + "%";
break;
case 3:
btnSwitch.SetBackgroundImage(AttributeItems.ImageFailerSwitch, UIControlState.Disabled);
btnSwitch.Enabled = false;
lblPercentage.TextColor = AttributeItems.TextColorFailureNotice;
lblPercentage.Text = item.AttendanceStatus + " " + item.Percentage.ToString("#.##") + "%";
break;
}
}
指导我这背后的原因是什么。我怎么能解决这个问题。