#import "mainviewcontroller.h"
@inte***ce
mainviewcontroller ()
//三個tableview作為屬性
@property(nonatomic,retain)uitableview *protableview;
@property(nonatomic,retain)uitableview *citytableview;
@property(nonatomic,retain)uitableview *zonetableview;
@property(nonatomic,retain)nsmutablearray *proarr;
@property(nonatomic,retain)nsmutablearray *cityarr;
@property(nonatomic,retain)nsmutablearray *zonearr;
@end
@implementation
mainviewcontroller
- (void)dealloc
- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil
return
self;
}- (void)createdata
else
if (![temp hasprefix:@" "] && [temp hasprefix:@" "])
else}}
- (void)viewdidload
- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section
if (tableview == self
.citytableview)
if (tableview == self
.zonetableview)
return0;}
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath
nsdictionary *dic = self
.proarr[indexpath.row];
cell.textlabel
.text = dic[@"proname"];
return cell;
}if (tableview == self
.citytableview)
nsmutabledictionary *citydic = self
.cityarr[indexpath.row];
cell.textlabel
.text = citydic[@"cityname"];
return cell;
}if (tableview == self
.zonetableview)
cell.textlabel
.text = self
.zonearr[indexpath.row];
return cell;
}return
nil;
}- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath
if (tableview == self
.citytableview)
}
簡單截圖
#warning 如果在初始化方法裡使用self.view,此時還沒有建立self.view,系統會自動呼叫loadview,建立乙個self.view,從而改變vc的執行的流程,所以我們只在初始化方法裡初始容器等資料部分,不建立檢視
//下面者兩個方法和上面的一模一樣
- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil
return
self;
}- (void)createdata
else
if (![temp hasprefix:@" "] && [temp hasprefix:@" "])
else
}}- (void)viewdidload
- (nsinteger)numberofsectionsintableview:(uitableview *)tableview
- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath
nsarray *arr = self
.proarr[indexpath.section][@"cityarr"];
nsdictionary *citydic = arr[indexpath.row];
cell.textlabel
.text = citydic[@"cityname"];
return cell;
}//下面兩個方法要用一起使用,有了第乙個方法,第二個方法才更加有意義
- (nsstring *)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section
- (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section
簡單截圖
用TableView寫帶特效的cell
用tableview寫帶特效的cell 效果 分析 在uiscrollview中的 中傳送廣播,然後在cell中接收廣播 對每乙個cell進行設定 對開發有利的一種小細節 核心原始碼 控制器原始碼 tableview created by xianmingyou on 15 4 9.import v...
TableView和Scrollview的混用
剛開始做ios,所以很多都不懂,把不會的記下來,可以幫助有需要的人,也可以留下自己學習路上的點滴 首先 在乙個vc裡新增乙個scrollview,然後,在scrollview裡新增3個vc tableview tableview viewcontroller 第一步 建立三個不同的vc 第二步 在v...
Qt model和tableview的使用
qt中的model和tableview都是採用index索引 index含有兩個成員變數乙個是row 乙個是column 對應該索引的行號 列號 model提供資料 view提供檢視 view用來顯示model的資料 必須將model繫結到某個view中才能顯示 ui tableview setmo...