欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

IOS開發(fā)之tableView點擊行跳轉(zhuǎn)并帶有“顯示”更多功能

 更新時間:2016年03月08日 11:09:48   作者:Livia.Chen  
這篇文章給大家介紹通過點擊城市中的tableView跳轉(zhuǎn)到旅游景點的tableView,下面會有“顯示”更多的功能,代碼簡單易懂,對ios點擊tableview跳轉(zhuǎn)相關(guān)知識感興趣的朋友一起學(xué)習(xí)吧

首先給大家展示下效果圖,覺得還滿意的話,請繼續(xù)學(xué)習(xí)代碼實現(xiàn)過程。

一,工程圖。


二,代碼。

RootViewController.h

#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController
<UITableViewDelegate,UITableViewDataSource>
{
UITableView * _tableView;
NSMutableArray * provinceArray;
}
@end 

RootViewController.m

#import "RootViewController.h"
//詳細頁面
#import "DetailViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
provinceArray = [[NSMutableArray alloc] initWithObjects:@"北京", @"上海", @"云南",@"四川",@"海南", @"江蘇", @"香港", @"澳門", @"西藏", nil];
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 380) style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
[self.view addSubview:_tableView];
}
#pragma -mark -UITableViewDelegate
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ID"] ;
}
cell.textLabel.text = [provinceArray objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 9;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 60;
}
//點擊進入下一頁
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController* svc = [[DetailViewController alloc] init];
svc.title = [NSString stringWithFormat:@"%@",[provinceArray objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:svc animated:NO];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end 

DetailViewController.h

#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController
<UITableViewDelegate,UITableViewDataSource>
{
UITableView* _tableView;
NSArray* provinceArr;
NSArray* cityArray;
NSString* cityName;
NSMutableArray* ditailName;
NSString* ditialPlaceName;
NSDictionary *dicForPlist;
}
@end 

DetailViewController.m

#import "DetailViewController.h"
static int rowNumber;
@interface DetailViewController ()
@end
@implementation DetailViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//傳過來的城市名字
cityName = self.title;
//tableView顯示行數(shù)
rowNumber = 20;
//tableView
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 460 ) style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
[self.view addSubview:_tableView];
NSMutableArray* cityComparearr = [[NSMutableArray alloc] init];
ditailName = [[NSMutableArray alloc] init];
//城市的plist文件
dicForPlist = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cityName" ofType:@"plist"]];
//北京所有數(shù)據(jù)
provinceArr = [dicForPlist objectForKey:cityName];
for (int j = 0; j < [provinceArr count]; j++) {//遍歷省的所有數(shù)據(jù)
cityArray = [provinceArr objectAtIndex:j];//取出每一個小數(shù)組
for (int i = 0; i < [cityArray count]; i++) {//遍歷小數(shù)組
NSString* strstr = [cityArray objectAtIndex:i]; //得到小數(shù)組內(nèi)容
if ([strstr isEqualToString:cityName] && j + 1 < [provinceArr count]) {
cityComparearr = [provinceArr objectAtIndex:j + 1];
if (![[cityArray objectAtIndex:i + 1] isEqualToString:[cityComparearr objectAtIndex:i + 1]]) {
[ditailName addObject:[cityArray objectAtIndex:i + 1]];
} else {
}
}
if ([strstr isEqualToString:cityName] && j + 1 == [provinceArr count]){
NSLog(@"last one?");
}
}
}
}
#pragma -mark -UITableViewDelegate
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ID"];
}
if (indexPath.section == 0) {
cell.textLabel.text = [ditailName objectAtIndex:indexPath.row];
}
if (indexPath.section == 1) {
cell.textLabel.text = @"顯示更多";
cell.textLabel.textAlignment = NSTextAlignmentCenter;
}
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
if (rowNumber > [ditailName count]) {//顯示到最多的時候
return [ditailName count];
}
return rowNumber;
} else
return 1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 1) {
rowNumber += 20;
[tableView reloadData];
} else {
NSLog(@"---跳轉(zhuǎn)到另外一個頁面----");
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end

以上內(nèi)容是小編給大家介紹的IOS開發(fā)之tableView點擊行跳轉(zhuǎn)并帶有“顯示”更多功能,有問題歡迎各位給我留言,我會及時和大家取得聯(lián)系的,同時感謝大家一直以來對腳本之家網(wǎng)站的支持。

相關(guān)文章

  • IOS開發(fā)中取消文本框輸入時的小鍵盤

    IOS開發(fā)中取消文本框輸入時的小鍵盤

    這篇文章主要介紹了IOS開發(fā)中取消文本框輸入時的小鍵盤,需要的朋友可以參考下
    2015-05-05
  • 解決ios audio無法播放問題

    解決ios audio無法播放問題

    這篇文章主要介紹了解決ios audio無法播放問題,并給大家分享了解決方法,需要的朋友參考一下。
    2017-11-11
  • iOS自定義轉(zhuǎn)場動畫的幾種情況

    iOS自定義轉(zhuǎn)場動畫的幾種情況

    這篇文章主要給大家介紹了關(guān)于iOS自定義轉(zhuǎn)場動畫的幾種情況,文中通過示例代碼介紹的非常詳細,對各位iOS開發(fā)者們具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-06-06
  • 個人對于異步和多線程的關(guān)系的理解分享

    個人對于異步和多線程的關(guān)系的理解分享

    異步和多線程并不是一個同等關(guān)系,異步是最終目的,多線程只是我們實現(xiàn)異步的一種手段。異步是當(dāng)一個調(diào)用請求發(fā)送給被調(diào)用者,而調(diào)用者不用等待其結(jié)果的返回而可以做其它的事情。
    2014-08-08
  • iOS - UIButton(UIEdgeInsets)/設(shè)置button上的文字和圖片上下垂直居中對齊

    iOS - UIButton(UIEdgeInsets)/設(shè)置button上的文字和圖片上下垂直居中對齊

    這篇文章主要介紹了iOS - UIButton(UIEdgeInsets)/設(shè)置button上的文字和圖片上下垂直居中對齊的相關(guān)資料,需要的朋友可以參考下
    2015-09-09
  • IOS開發(fā)實現(xiàn)錄音功能

    IOS開發(fā)實現(xiàn)錄音功能

    本文給大家分享的是一個IOS開發(fā)中實現(xiàn)錄音功能的實例,并簡單給大家解析一下,有需要的小伙伴可以參考下
    2016-03-03
  • IOS中UITextView或UITextField字數(shù)限制的實現(xiàn)

    IOS中UITextView或UITextField字數(shù)限制的實現(xiàn)

    這篇文章主要介紹了IOS中UITextView或UITextField字數(shù)限制的實現(xiàn)的相關(guān)資料,希望通過本文能幫助到大家實現(xiàn)這樣的功能,需要的朋友可以參考下
    2017-10-10
  • IOS中內(nèi)存管理那些事

    IOS中內(nèi)存管理那些事

    這篇文章主要介紹了IOS中內(nèi)存管理那些事的相關(guān)資料,需要的朋友可以參考下
    2015-11-11
  • 百度地圖PC端判斷用戶是否在配送范圍內(nèi)

    百度地圖PC端判斷用戶是否在配送范圍內(nèi)

    在pc端設(shè)置商家的配送范圍,用戶在下單時,根據(jù)用戶設(shè)置的配送地點判斷是否在可配送范圍內(nèi),并給用戶相應(yīng)的提示,下面通過本文給大家分享具有實現(xiàn)代碼,感興趣的朋友一起學(xué)習(xí)吧
    2016-01-01
  • iOS實現(xiàn)無限滑動效果

    iOS實現(xiàn)無限滑動效果

    這篇文章主要為大家詳細介紹了iOS實現(xiàn)無限滑動效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03

最新評論