Friday, 20 December 2013

Removing extra separator lines for empty rows in UITableView

- (void) viewDidLoad
{
  [super viewDidLoad];

  self.tableView.tableFooterView = [[[UIView alloc] init] autorelease];
}

Tuesday, 17 December 2013

iPhone - Create custom UITableViewCell top and bottom borders

tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

// Draw top border only on first cell
if (indexPath.row == 0) {
    UIView *topLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 1)];
    topLineView.backgroundColor = [UIColor grayColor];
    [cell.contentView addSubview:topLineView];
}

UIView *bottomLineView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.bounds.size.height, self.view.bounds.size.width, 1)];
bottomLineView.backgroundColor = [UIColor grayColor];

[cell.contentView addSubview:bottomLineView];

Tuesday, 10 December 2013

How to check document directory file your image is there or not

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
    NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:@"/progress/before.png"];

  if (![[NSFileManager defaultManager] fileExistsAtPath:imagePath])
    {
       //file not exits in Document Directories
        imageviewname.image = [UIImage imageNamed:@"add_photo_block_hires.png"];
    }
    else
    {
        //file exist in Document Directories
         imageviewname.image =[UIImage imageWithContentsOfFile:imagePath1];

    }

Monday, 9 December 2013

How to remove uiview from uiscrollview in iphone

      if([viewname superview]!=nil)
        {
            for(UIView *subview in [scrollviewname subviews]) {
                if([subview isKindOfClass:[viewname class]]) {
                    [subview removeFromSuperview];
                }
            }

        }

Friday, 6 December 2013

Pop back to a specific viewcontroller in the navigationController

[self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:2] animated:YES];