开发者

How to display Two tables on a UI view

I would like to use and display two tables开发者_开发知识库 on a UI view. Please let me know how to do this. Any code same will also be appreciated.

Thanks, Sandeep


  1. Add 2 UITableViews to your view in IB and connect them to 2 different outlets in file owner (or simply assign different tag properties).
  2. Set delegate and data source for them (may be same view controller for both).
  3. In delegate/data source methods you do the following:

    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    
        if (tableView == myFirstTable)
            // return value for 1st table
        if (tableView == mySecondTable)
            // return value for 2nd table
         return 0;
    }
    

or if you use tag approach:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{   
    switch(tableView.tag){
         case firstTag:
            // return value for 1st table
         case secondTag: 
            // return value for 2nd table
    }
    return 0;
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜