0
UITableViewCell
にUIButton
の時刻を設定したいとします。 1つのボタンをクリックすると動作しますが、2つ以上のボタンをクリックするとタイマーは停止しません。 startTimer
でUITableViewCellボタンからタイマーを設定する
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
tabletTextLabel.text=[appDelegate.tabletArray objectAtIndex:indexPath.row];
noOfTabletTextLabel.text=[appDelegate.noOfTabletsArray objectAtIndex:indexPath.row];
[cellButton setImage:[appDelegate.imageArray objectAtIndex:indexPath.row] forState:UIControlStateNormal];
[cellButton addTarget:self action:@selector(CellButtonClick:) forControlEvents:UIControlEventTouchUpInside];
cellButton.tag = indexPath.row;
// cell.accessoryView = cellButton;
[cell.contentView addSubview:presTextLabel];
[cell.contentView addSubview:tabletTextLabel];
[cell.contentView addSubview:noOfTabletTextLabel];
[cell.contentView addSubview:cellButton];
return cell;
}
-(void)CellButtonClick:(id)sender
{
UIButton *button = (UIButton *)sender;
NSLog(@"%d", button.tag);
[self StartTimer];
}
-(void)StartTimer
{
timer=[NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(SetTabletAlert) userInfo:nil repeats:YES];
}
-(void)SetTabletAlert
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Reminder"
message:@"Take Tablets"
delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"ok"])
{
if(timer)
{
[timer invalidate];
timer=nil;
}
}
}
おかげで男....ちょっとuはときに、ユーザーの押しボタン..heyを助けることができるし、別の画像は、その画像の上にすべきであり、取り外したときに、再びユーザー私を助けpresses..please .. – sharanu
についてボタンの問題です。 'UIImageView'の' hidden'プロパティを 'YES'または' NO'に設定するボタンに '@ selector'アクションを割り当てるだけです。 'UIImageView'を(' UIButtonTypeCustom'型の)目に見えない 'UIButton'を' @ selector'アクションでオーバーレイして隠すことができます。 – Mundi