1

To show the content in a my self-defined long tableViewCell,I create a scroll view and add a scroll-unable tableView in my scroll view with the tableviewcell is kind of my self-defined tableviewcell.

in my TollStatusViewController.h

UITableView *selfTableView;
@property (retain, nonatomic) IBOutlet UIScrollView *fluxScrollView;

in my TollStatusViewController.m

self.fluxScrollView.clipsToBounds = YES;
self.fluxScrollView.indicatorStyle = UIScrollViewIndicatorStyleBlack;
[self.fluxScrollView setContentSize:CGSizeMake(1400.0, 154.0)];

selfTableView = [[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 1400.0, 154.0) style:UITableViewStylePlain] autorelease];
selfTableView.dataSource = self;

selfTableView.delegate = self;
selfTableView.scrollEnabled = NO;
[self.fluxScrollView addSubview:selfTableView];

and the delegate methods:

#pragma mark tableview-data-source

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

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

- (CGFloat)tableView:(UITableView *)_tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 38.0;
    }
    if (indexPath.row == 1) {
        return 56.0;
    }
    if (indexPath.row == 2) {
        return 56.0;
    }
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    ManyColumnsViewCell *cellView = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cellView == nil) {
        cellView = [[[ManyColumnsViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }


    return cellView;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

}

Then I can enable the horizontal scrolling for my fluxScrollView so i can show the content in my long manyColumnsViewCell.

but when click one row in the tableView,there is a crash with hint

2012-08-17 15:43:14.789 MScope[2261:13a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType tableView:didSelectRowAtIndexPath:]: unrecognized selector sent to instance 0x7e87960'

and after i remove this function

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {

    }

there is no crash.

chenakira
  • 131
  • 1
  • 10

1 Answers1

1

the most voting answer here

My TollStatusViewController was built temporarily ,so I retain it in its object and dealloc in the object's function -(void)dealloc,then it will be fine.

Community
  • 1
  • 1
chenakira
  • 131
  • 1
  • 10