最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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"
//詳細(xì)頁面
#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;
}
//點擊進(jìn)入下一頁
- (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中UIWebView加載Loading的實現(xiàn)方法

    IOS中UIWebView加載Loading的實現(xiàn)方法

    最近有朋友問我類似微信語音播放的喇叭動畫和界面圖片加載loading界面是怎樣實現(xiàn)的,是不是就是一個gif圖片呢!我的回答當(dāng)然是否定了,當(dāng)然不排除也有人用gif圖片??!
    2015-05-05
  • IOS開發(fā)之適配iOS10及Xcode8的注意點

    IOS開發(fā)之適配iOS10及Xcode8的注意點

    這篇文章主要介紹了IOS開發(fā)之適配iOS10及Xcode8的注意點,本文給大家介紹了可能出現(xiàn)的問題及相應(yīng)的解決方法,非常不錯具有參考借鑒價值,感興趣的朋友一起看看
    2016-10-10
  • 詳解iOS webview加載時序和緩存問題總結(jié)

    詳解iOS webview加載時序和緩存問題總結(jié)

    本篇文章主要介紹了iOS webview加載時序和緩存問題總結(jié) ,這兩天學(xué)習(xí)了Vue.js 感覺組件這個地方知識點挺多的,而且很重要,所以,今天添加一點小筆記。
    2017-09-09
  • 詳解IOS點擊空白處隱藏鍵盤的幾種方法介紹

    詳解IOS點擊空白處隱藏鍵盤的幾種方法介紹

    本篇文章主要介紹了IOS點擊空白處隱藏鍵盤的幾種方法,非常具有實用價值,需要的朋友可以參考下。
    2016-12-12
  • iOS使用CoreMotion實現(xiàn)搖一搖功能

    iOS使用CoreMotion實現(xiàn)搖一搖功能

    這篇文章主要為大家詳細(xì)介紹了iOS使用CoreMotion實現(xiàn)搖一搖功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • iOS微信瀏覽器回退不刷新實例(監(jiān)聽瀏覽器回退事件)

    iOS微信瀏覽器回退不刷新實例(監(jiān)聽瀏覽器回退事件)

    下面小編就為大家?guī)硪黄猧OS微信瀏覽器回退不刷新實例(監(jiān)聽瀏覽器回退事件)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • iOS開發(fā)之統(tǒng)計Xcode工程的代碼行數(shù)

    iOS開發(fā)之統(tǒng)計Xcode工程的代碼行數(shù)

    這篇文章主要給大家介紹了在iOS開發(fā)中,如果想要統(tǒng)計Xcode工程的代碼行數(shù)該如何實現(xiàn),文章給出了詳細(xì)的方法和示例代碼,對大家的理解和學(xué)習(xí)很有幫助,本文中還分享了統(tǒng)計java文件和xml文件的代碼,有需要的朋友們下面來一起看看吧。
    2016-10-10
  • iOS tableView實現(xiàn)單選和多選的實例代碼

    iOS tableView實現(xiàn)單選和多選的實例代碼

    本篇文章主要介紹了iOS tableView實現(xiàn)單選和多選的實例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-07-07
  • iOS逆向開發(fā)之微信自動添加好友功能

    iOS逆向開發(fā)之微信自動添加好友功能

    這篇文章主要介紹了iOS逆向開發(fā)之微信自動添加好友功能,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-04-04
  • 簡單談?wù)刢/c++中#import、#include和@class的區(qū)別

    簡單談?wù)刢/c++中#import、#include和@class的區(qū)別

    對于#import,我想做過iOS開發(fā)的人應(yīng)該都不陌生。在開發(fā)過程中,當(dāng)我們需要聲明某一個類時,都需要去引用。而#imclude的話,在我們學(xué)習(xí)C時就已經(jīng)知道了,他的作用也是引用聲明的意思。在表面上他們的作用似乎都是一樣的。但是在具體功能實現(xiàn)方式上,還是有著很大的區(qū)別。
    2018-01-01

最新評論

安丘市| 赣州市| 南昌市| 类乌齐县| 垣曲县| 昭苏县| 札达县| 宝丰县| 丰原市| 彭山县| 道真| 汉源县| 黎川县| 昌图县| 金溪县| 元谋县| 确山县| 资阳市| 乐昌市| 临泽县| 盐边县| 丰顺县| 定远县| 黄大仙区| 琼结县| 天峨县| 衢州市| 黑龙江省| 安义县| 曲阳县| 乌鲁木齐县| 绥滨县| 达日县| 始兴县| 平昌县| 庄河市| 盐城市| 阿巴嘎旗| 内乡县| 若尔盖县| 永靖县|