我有一个带有 1 节和两行的 tableview,向下我有一个按钮操作。
在按钮操作中,我必须检查单击了哪个单元格,因为根据该单元格,我必须打开电子邮件视图以发送邮件。
我为两个布尔值创建了,但它不能正常工作,仍然选择了我的 emailview 没有单元格的调用这个代码我在做什么
@implementation View
@synthesize Mytableview,selectedIndexPaths,value1,value2,cellselected;
BOOL values[1];
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [Mytableview dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
if ([indexPath row] == 0 && [indexPath section] == 0)
{
cell.textLabel.text= @"test";
if (values[indexPath.row]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
value1=TRUE;
}
else if ([indexPath row] == 1 && [indexPath section] == 0)
{
cell.textLabel.text= @"test";
value2=TRUE;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//[Mytableview deselectRowAtIndexPath:indexPath animated:YES];
//self.cellselected = indexPath.row;
UITableViewCell *cell = [Mytableview cellForRowAtIndexPath:indexPath];
//here values is i give as array on top as BOOL values[1];i give size for it
values[indexPath.row] = !values[indexPath.row];
if (values[indexPath.row]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
-(IBAction)ExportEmail
{
if (value1==FALSE) {
return;
}
else {
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
// We must always check whether the current device is configured for sending emails
if ([mailClass canSendMail])
{
[self displayComposerSheet];
}
}
}
}