2014-09-10 44 views
0

我目前有一个提醒按钮,我想改变,所以而不是点击一个单元格去它里面,我想使用按钮。更改提醒按钮,以打开屏幕

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index 
{ 
    switch (index) { 
     case 0: 

    { 
     NSLog(@"More button was pressed"); 
     UIAlertView *alertTest = [[UIAlertView alloc] initWithTitle:@"Hello" message:@"More more more" delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles: nil]; 
     [alertTest show]; 

     [cell hideUtilityButtonsAnimated:YES]; 
     break; 
    } 

如何集成与此:

- (void)tableView:(UITableView *)tableView 
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    BNRDetailViewController *detailViewController = 
           [[BNRDetailViewController alloc] init]; 

    // Push it onto the top of the navigation controller's stack 
    [self.navigationController pushViewController:detailViewController 
             animated:YES]; 
} 
+0

如果您的意思是您试图在显示的警报视图上使用按钮,则需要添加一个不取消按钮并实现UIAlertViewDelegate以处理单击的警报视图按钮。在处理按钮点击的方法中,您可以初始化BNRDetailViewController并将其推送。 [alertView:didDismissWithButtonIndex:](https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertViewDelegate_Protocol/UIAlertViewDelegate/UIAlertViewDelegate.html#//apple_ref/doc/uid/TP40007548-CH3-SW1)是您需要实现的UIAlertViewDelegate方法 – trevorj 2014-09-10 11:57:20

回答

0

如果你的意思是从警报视图点击推新控制器,你就必须添加UIAlertViewDelegate和消息警报视图中的另一个按钮。然后调用clickedButtonAtIndex方法

-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 


if (buttonIndex == [alertView firstOtherButtonIndex] && [alertview.title isEqualToString:@"Hello"]) { 


    [self.navigationController pushViewController:detailViewController 
            animated:YES]; 

    } 
} 
1

如果你的意思是你想要的是揭示了按钮,当用户刷卡的实现代码如下行推动的,而不是显示一个警报视图视图 - 控制,这是你想要做什么:

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index 
{ 
    switch (index) { 
     case 0: 

    { 
     BNRDetailViewController *detailViewController = [[BNRDetailViewController alloc] init]; 

     // Push it onto the top of the navigation controller's stack 
     [self.navigationController pushViewController:detailViewController 
            animated:YES]; 

     [cell hideUtilityButtonsAnimated:YES]; 
     break; 
    }