开发者

Cell specific Action like slide-in menu

开发者 https://www.devze.com 2022-12-20 09:15 出处:网络
I\'m attempting to implement a slide-in menu like in the facebook app. I have a NIB for a custom UITableViewCell, which includes a button.

I'm attempting to implement a slide-in menu like in the facebook app.

I have a NIB for a custom UITableViewCell, which includes a button. The button has an IBAction associated with it, in which I animate in a subview of my NIB (the delete/edit menu).

My problem is that my animation only happens on one cell, and its not the cell where I pushed the button.

How would I call this animation to work on the cell where my button was tapped? Here's my code so far. Any tips?

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *PatientCellIdentifier = @"PatientCellIdentifier";
PatientListTableViewCell *cell = (PatientListTableViewCell *)[tableView dequeueReusableCellWithIdentifier:PatientCellIdentifier];
if (cell ==nil) {
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"PatientCell" owner:self options:nil];
    cell = [nib objectAtIndex:0];
    cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellBG.png"]];
}
//NSUInteger row = [indexPath row];
//NSDictionary *rowData = [self.
[self configureCell:cell atIndexPath:indexPath];
return cell; }

-(IBAction)showMenu:(id)se开发者_StackOverflow中文版nder{
[self showMenuForCell:sender animated:YES];}

- (void)showMenuForCell:(UITableViewCell *)cell animated:(BOOL)animated {
//[super showMenu:view forCell:cell animated:animated];   
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
//Action here
[UIView commitAnimations];

}


Is this included in your code?

[self.contentView addSubview:SLIDINGVIEW];

We need to look at your animation block and the code that invokes your animation


I solved this problem Myself. I ended up using a custom Subclass of UITableViewCell outlined in 'Beginning iPhone Development' pp 205-208.

I put a button in the NIB for my cell, with one view for the normal view, and another for the menu. When the button was pushed. The main view slides out of the way. All of these methods and buttons were included in the subClass. Boom. done.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号