小编meg*_*eng的帖子

第一次点击时没有调用UITableView didSelectRowAtIndexPath

我遇到了UITableView的ios 5的didSelectRowAtIndexPath问题,这在ios 4中是正确的.

我第一次点击表中的任何一行时,该方法不会被调用.一旦我选择了另一行,它就会调用didSelectRowAtIndexPath,但会传递最后一个indexPath.

我已经设置了tableView.delegate,它可以在ios4中正确运行.

MainView.xib
UITabBarController
     --UINavigationController
         --**UITableViewController**
Run Code Online (Sandbox Code Playgroud)

有什么建议?

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.textLabel.text = [[NSString alloc]initWithFormat:@"%d",indexPath.row];
    return cell; …
Run Code Online (Sandbox Code Playgroud)

uitableview didselectrowatindexpath ios5

27
推荐指数
2
解决办法
1万
查看次数