Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (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.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
- UIView * contentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
- UIImageView * cellImg = [[UIImageView alloc]initWithFrame:CGRectMake(5,8,259, 60)];
- [cellImg setImage:[UIImage imageNamed:[menuArr objectAtIndex:indexPath.row]]];
- [contentView addSubview:cellImg];
- [contentView setBackgroundColor:[UIColor clearColor]];
- [cell.contentView addSubview:contentView];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- delegate.sideBarSelectedIndex = indexPath.row;
- NSLog(@"delegate.sideBarSelectedIndex: %d",delegate.sideBarSelectedIndex);
- [UIView commitAnimations];
- if (self.sidebarDelegate) {
- NSObject *object = [NSString stringWithFormat:@"ViewController%d", indexPath.row];
- [self.sidebarDelegate sidebarViewController:self didSelectObject:object atIndexPath:indexPath];
- [delegate.firstLensePageObj timerFunction:indexPath.row];
- }
- }
- UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- cell.imageView.image = [UIImage imageNamed:@"yourImage"];
- UIImageView *selectedImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Your Image"]];
- cell.selectedBackgroundView = selectedImageView;
- - (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.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
- UIView * contentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
- UIImageView * cellImg = [[UIImageView alloc]initWithFrame:CGRectMake(5,8,259, 60)];
- if (delegate.sideBarSelectedIndex == indexpath.row){
- //Selected cell
- [cellImg setImage:[UIImage imageNamed:[selectedMenuArr objectAtIndex:indexPath.row]]];
- }else {
- //Unselected cell
- [cellImg setImage:[UIImage imageNamed:[menuArr objectAtIndex:indexPath.row]]];
- }
- [contentView addSubview:cellImg];
- [contentView setBackgroundColor:[UIColor clearColor]];
- [cell.contentView addSubview:contentView];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- delegate.sideBarSelectedIndex = indexPath.row;
- NSLog(@"delegate.sideBarSelectedIndex: %d",delegate.sideBarSelectedIndex);
- [UIView commitAnimations];
- if (self.sidebarDelegate) {
- NSObject *object = [NSString stringWithFormat:@"ViewController%d", indexPath.row];
- [self.sidebarDelegate sidebarViewController:self didSelectObject:object atIndexPath:indexPath];
- [delegate.firstLensePageObj timerFunction:indexPath.row];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement