我目前有一个警告按钮,我想更改,所以我没有点击一个单元格进入它,我想使用按钮。
- (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 :(得分:1)
如果您想要在用户滑动tableview行时显示的按钮推送视图控件而不是显示警报视图,那么这就是您要执行的操作:
- (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;
}
答案 1 :(得分:0)
如果您想通过单击警报视图来推送新控制器,则必须在警报视图中添加UIAlertViewDelegate和另一个按钮的消息。然后调用clickedButtonAtIndex方法
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == [alertView firstOtherButtonIndex] && [alertview.title isEqualToString:@"Hello"]) {
[self.navigationController pushViewController:detailViewController
animated:YES];
}
}