相关疑难解决方法(0)

使用Objective-C中的类别覆盖方法

我可以使用类类别来覆盖已使用类别实现的方法吗?像这样:

1)原始方法

-(BOOL) method {
  return true;
}
Run Code Online (Sandbox Code Playgroud)

2)覆盖方法

-(BOOL) method {
  NSLog(@"error?"); 
  return true; 
}
Run Code Online (Sandbox Code Playgroud)

这会起作用,还是非法的?

objective-c categories

87
推荐指数
3
解决办法
5万
查看次数

如何在Swift中添加双击手势识别器

我已经完成了一个单击识别器,但无法弄清楚如何将该单击识别器改为双击.我可以使用一些指导.

码:

import Foundation
import UIKit

class MainBoardController: UIViewController{

    let tap = UITapGestureRecognizer()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        var swipe: UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: "GotoProfile")
        swipe.direction = UISwipeGestureRecognizerDirection.Right
                    self.view.addGestureRecognizer(swipe)

        tap.addTarget(self, action: "GotoCamera")
        view.userInteractionEnabled = true
        view.addGestureRecognizer(tap)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func GotoProfile(){
        self.performSegueWithIdentifier("Profilesegue", sender: nil)
    }

    func GotoCamera(){
        self.performSegueWithIdentifier("Camerasegue", sender: nil)
    }
}
Run Code Online (Sandbox Code Playgroud)

uigesturerecognizer swift

12
推荐指数
4
解决办法
2万
查看次数

如何在tableview中检测双击/触摸事件

经过长时间但徒劳无功的搜索,我无法在我的tableview中检测到双击/触摸事件,实际上想要双击任何细节视图TableViewCell,实际上我甚至不知道如何在所有.

到目前为止这是我的代码......

viewDidLoad中

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self    action:@selector(handleTapGesture:)];
tapGesture.numberOfTapsRequired = 2;
[self.myTable addGestureRecognizer:tapGesture];
Run Code Online (Sandbox Code Playgroud)

handleTapGesture方法是

- (void)handleTapGesture:(UITapGestureRecognizer *)sender {
  if (sender.state == UIGestureRecognizerStateRecognized) {
      flag = true;
  }
}
Run Code Online (Sandbox Code Playgroud)

最后触摸或点击tableview的单元格,委托方法是

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (flag == true)
    {
        DetailInvoicing *detail = [[DetailInvoicing alloc] initWithNibName:@"DetailInvoicing" bundle:nil];
        detail.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        detail.customerName = [customerArray objectAtIndex:indexPath.row];
        [self presentViewController:detail animated:YES completion:nil];
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我删除此标志条件,则只需单击即可调用新视图.我错在哪里或者还有其他方法可以做到这一点.

iphone objective-c uitableview ios

6
推荐指数
2
解决办法
4420
查看次数

在 uitableviewcell 上禁用多次点击

我有一个 uitableview,它在点击单元格时实现弹出( PopoverView ),然后弹出框将在屏幕上的任何其他点击时关闭。问题是,如果用户想要双击或重复点击单元格,它将导致显示多个 popoverviews 实例,然后应用程序将崩溃..我正在寻找一种方法来禁用双击单元格和/ 或UITableView一般或有没有办法延迟接触UITableViewCell任何想法?

我已经尝试过这个,但它在我的情况下不起作用。另一种方法是检查 PopoverView 是否已经存在,如果存在,则不允许另一个实例化。我试过这个这个,在我的情况下都不起作用。

这是我调用 popover 视图的代码didSelectRowAtIndexpath

- (void)tableView:(UITableView *)TableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   UITableViewCell *cell = [TableView cellForRowAtIndexPath:indexPath];
sti = [[SelectedTeamsInfo alloc] init];
MyLeagueStandings *info = [fetchedResultsController objectAtIndexPath:indexPath];
[sti getAllScheduleForTeam:info.urlforteam];
NSString *title = info.teamname;

// If title length is greater then 32 truncate it to fit.
if (title.length > 32) {
    title = [info.teamname substringToIndex:29];
    title = [title stringByAppendingString:@"..."];
} …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch uitableview

5
推荐指数
1
解决办法
3192
查看次数

iOS如何知道UITableView中是否第二次点击了一行?

我正在开发一个iOS 5应用程序,在我的情况下,如果用户第一次从UITableView点击一行然后它将执行一些操作,如果它被第二次点击,那么它将执行不同的操作.

现在,问题是如何知道特定行是否第二次被点击?

提前致谢!!

objective-c uitableview ios5

1
推荐指数
1
解决办法
711
查看次数