Search code examples
iosios6uikituitableview

iOS UIKit controllers to present news feed with photos


I am a newbie to iOS and developing a social application for iPhone (build using iOS 6 SDK).

One of the main pages of my application is the vertically scrolled news feed, sorted by time, that should generally display status updates. Each status update presents the user name, a user thumbnail photo, some content text and most probably some photos or videos along with few buttons to like or share with expandable comments list.

The status updates content are all stored in a RESTtful remote server.

It made me some sense to implement it with UITableViewcontroller, that also offers refreshing for free:

  1. How can I create a custom Subtitle style UITableViewCell with a large image/video below (something like with Facebook or Instagram)? are there any code examples for creating this customized cell?

  2. If it should not be constructed using the UITableViewCell/UITableViewController, which other iOS UIKit controllers should be used in order to present this news feed?

  3. There are probably some great ready to use open source frameworks for that - which would you recommend?

Thanks a bunch in advance, Asaf


Solution

  • Their are many tutorials you can download source code and can read apple documentation of UITableView and here you can see the tutorial Here . Below is the code for basic showing the image,title and subtitle by default

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
            NSString *CellIdentifier =@"Cell";
            UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
            if (cell == nil)
            {
                cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }
            cell.imageView.image=[UIImage imageNamed:[imageArray objectAtIndex:indexPath.row]];
            cell.textLabel.text=[titleArray objectAtIndex:indexPath.row];
            cell.detailTextLabel.text=[subtitle objectAtIndexPath.row];
        return cell;
        }
    

    If u want to make a custom cell then, set frames according to your need and use SDWebImage library to cache the images

    UserImageView =[[UIImageView alloc]initWithFrame:CGRectMake(5,0,70, 70) ];
    nameLbl=[[UILabel alloc]initWithFrame:CGRectMake(95, 20, 200, 20)];
    [nameLbl setText:nameStr];
    [UserImageView setImageWithURL:[NSURL URLWithString:responseString] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    [cell.contentView addSubview:nameLbl];
    [cell.contentView addSubview:UserImageView];