IOS implements QQ interface and iosqq Interface

Source: Internet
Author: User

IOS implements QQ interface and iosqq Interface

Compile a QQ interface as requested by the master to help me solve the code problem.

Compile a QQ interface with three groups, each of which is attended and shows that the group is online or offline;

Let's take a look.

This saves some trouble because I only use one image. If you want to set it based on different people, you just need to change it in the cell;

Click the group above to expand the content, and then click "retrieve.

Not much nonsense. serving food:

Let's first construct the data:

NSArray * InitArray = @ [@ {@ "Name": @ "friend", @ "Group": @ "YES", @ "Child ": @ [@ {@ "Name": @ "Zhang San", @ "State": @ "online", },{ @ "Name": @ "Wang Wu ", @ "State": @ ""}]}, @ {@ "Name": @ "family", @ "Group": @ "YES", @ "Child ": @ [@ {@ "Name": @ "", @ "State": @ ""}, @ {@ "Name": @ "", @ "State": @ "online"}, @ {@ "Name": @ "", @ "State": @" "}, @ {@ "Name": @ "", @ "State": @ ""}]}, @ {@ "Name": @ "Stranger ", @ "Group": @ "YES", @ "Child": @ [@ {@ "Name": @ "Xiao Wang", @ "State": @ "online "}, @ {@ "Name": @ "Xiao Li", @ "State": @ ""}, @ {@ "Name": @ "xiao hong", @ "State ": @ "exit"}];

Set an array attribute to accept data;

@property (nonatomic,copy) NSMutableArray * CellArray;

Okay. Let's use the data to construct the interface;

The interface is simple:

An image is your own profile picture;

One is your own network name

An online status

The following is a table (tableview)

@interface ViewController (){    UITableView * TableV;}@end

Set a tableview;

Put it inside:

UIImageView * IconImageV = [[UIImageView alloc] initWithFrame: CGRectMake (15, 30, 60, 60)]; IconImageV. image = [UIImage imageNamed: @ "icon.png"]; [self. view addSubview: IconImageV]; UILabel * NameLabel = [[UILabel alloc] initWithFrame: CGRectMake (100, 30,100, 30)]; NameLabel. text = @ "cedar"; NameLabel. textAlignment = 1; // set the text to center in the way [self. view addSubview: NameLabel]; UILabel * StateLabel = [[UILabel alloc] initWithFrame: CGRectMake (100, 60,100, 30)]; StateLabel. text = @ "online"; NameLabel. textAlignment = 1; [self. view addSubview: StateLabel]; TableV = [[UITableView alloc] initWithFrame: CGRectMake (15,100,290,350)]; TableV. delegate = self; TableV. dataSource = self; TableV. separatorStyle = 0; TableV. backgroundColor = [UIColor yellowColor]; [self. view addSubview: TableV];

Then let's construct the table.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{        UITableViewCell *cell ;    NSDictionary * dectionary = [_CellArray objectAtIndex:indexPath.row];    if([dectionary objectForKey:@"Group"])    {        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"Group"];        cell.textLabel.text = [dectionary objectForKey:@"Name"];        cell.textLabel.textAlignment=0;        cell.backgroundColor = [UIColor grayColor];        cell.tag = 1;    }    else    {        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Child"];        cell.imageView.image = [UIImage imageNamed: @"icon.png"];        cell.textLabel.text = [dectionary objectForKey:@"Name"];        cell.detailTextLabel.text = [dectionary objectForKey:@"State"];    }    return cell;    }

Here I want to talk about this tag. I 've been thinking about it for a long time. There is no way to record whether the group is opened or collapsed, finally, we thought that the tag is folded in the format of tag = 1, and opened in the format of tag = 2;

The following are the most difficult methods to fold and open;

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{    NSMutableDictionary * dictionary = [NSMutableDictionary dictionaryWithDictionary:[_CellArray objectAtIndex:indexPath.row]];        UITableViewCell *cell = [TableV cellForRowAtIndexPath:indexPath];    NSLog(@"%@",cell.textLabel.text);    if([dictionary objectForKey:@"Group"])    {        NSArray *ChildArray = [dictionary objectForKey:@"Child"];        NSMutableArray *PathArray = [NSMutableArray array];                if(cell.tag==1)        {            cell.tag=2;            for (int i =0 ;i<ChildArray.count;i++)            {                dictionary = [ChildArray objectAtIndex:i];                [_CellArray insertObject:dictionary atIndex:i+indexPath.row+1];                NSIndexPath *path = [NSIndexPath indexPathForRow:i+indexPath.row+1 inSection:0];                [PathArray addObject:path];            }            [TableV insertRowsAtIndexPaths:PathArray withRowAnimation:UITableViewRowAnimationAutomatic];        }        else        {            cell.tag=1;            NSMutableIndexSet * deleteSet= [NSMutableIndexSet indexSet];            for (NSDictionary *dic  in ChildArray)            {                NSInteger row= [_CellArray indexOfObject:dic];                NSIndexPath * Path = [NSIndexPath indexPathForRow:row inSection:0];                [PathArray addObject:Path];                [deleteSet addIndex:row];            }            [_CellArray removeObjectsAtIndexes:deleteSet];            [TableV deleteRowsAtIndexPaths:PathArray withRowAnimation:UITableViewRowAnimationBottom];        }    }    }

The above is a specific way, if you do not understand, then go to view my other blog http://blog.csdn.net/u010123208/article/details/38176943

Okay, the source code of the QQ interface is in

Http://download.csdn.net/detail/u010123208/7774851

Welcome to download


Qq interfaces and functions of android and iOS can be compared.

The QQ interface on IOS is very beautiful, but its functions are not complete. In addition to the bad Chinese Input on IOS, it is a nightmare to talk about Q on the iphone...

How can I reload interface data for ios development?

Data loading can generally be written in viewdidload. After the network data is obtained successfully, reconfigure the global control to be configured. Try not to write time-consuming code in viewwillAppear, which affects the user experience.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.