001.
- (
id
)initWithNibName:(
NSString
*)nibNameOrNil bundle:(
NSBundle
*)nibBundleOrNil
002.
{
003.
self
= [
super
initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
004.
if
(
self
) {
005.
006.
}
007.
return
self
;
008.
}
009.
010.
011.
-(
void
)GetTableDataFromWeb{
012.
NSString
*dict = [
NSString
stringWithFormat:@
"{\"act\":\"placelist\",\"cid\":\"%d\",\"search\":\"%@\"}"
,infoRow+1,infoSearch];
013.
NSLog
(dict);
014.
infoSearch = [
NSString
stringWithFormat:@
""
];
015.
MyAppCore *core = [[MyAppCore alloc] init];
016.
[core SendData2Server:dict rsObject:
self
];
017.
018.
}
019.
-(
void
)GetDataFromServer:(
id
)rs
020.
{
021.
NSLog
(@
"DATA MA LAEW mmmmmm : %@"
,rs);
022.
NSObject
*obj_result = [rs objectForKey:@
"res"
];
023.
NSInteger
iRes =[[
NSString
stringWithFormat:@
"%@"
,obj_result] intValue];
024.
if
(iRes>0){
025.
NSObject
*obj_c = [rs objectForKey:@
"count"
];
026.
NSInteger
iCount =[[
NSString
stringWithFormat:@
"%@"
,obj_c] intValue];
027.
NSMutableArray
*tempArray = [[
NSMutableArray
alloc] init];
028.
NSString
*strData[10];
029.
for
(
int
i=0;i<iCount;i++){
030.
NSObject
*obj_id = [rs objectForKey:[
NSString
stringWithFormat:@
"id%d"
,i]];
031.
NSInteger
iID =[[
NSString
stringWithFormat:@
"%@"
,obj_id] intValue];
032.
idArray[i] = iID;
033.
034.
NSObject
*obj_data = [rs objectForKey:[
NSString
stringWithFormat:@
"data%d"
,i]];
035.
strData[i] =[
NSString
stringWithFormat:@
"%@"
,obj_data];
036.
037.
038.
039.
040.
041.
}
042.
[tempArray addObject:@
"AAA"
];
043.
044.
NSArray
*names_array = [
NSArray
arrayWithObjects:strData count:iCount];
045.
NSArray
*infoArray = [
NSArray
arrayWithObjects:@
"ร้านA"
,@
"ร้านB"
,
nil
];
046.
tableInfo = names_array;
047.
[sendDataTable reloadData];
048.
}
else
{
049.
NSLog
(@
"NOT OK LA NA"
);
050.
}
051.
}
052.
053.
054.
055.
056.
057.
- (
void
)viewDidLoad
058.
{
059.
[
super
viewDidLoad];
060.
{
061.
[
super
viewDidLoad];
062.
tableInfo = [
NSArray
arrayWithObjects:@
"ดอยอินทนนท์"
,@
"กิ่วแม่ปาน"
,@
"น้ำตกแม่กลาง"
,@
"น้ำตกวชิรธาร"
,
063.
@
"สถานีเกษตรหลวง"
,@
"ถ้ำบรินจินดา"
,@
"น้ำตกแม่ยะ"
,@
"ออบหลวง"
,@
"ออบหลวง"
,@
"ออบหลวง"
,
nil
];
064.
065.
066.
imageinfo = [
NSArray
arrayWithObjects:@
"moutain2.png"
,@
"moutain2.png"
,@
"moutain2.png"
,@
"moutain2.png"
,
067.
@
"moutain2.png"
,@
"moutain2.png"
,@
"moutain2.png"
,@
"moutain2.png"
,@
"moutain2.png"
,@
"moutain2.png"
,
nil
];
068.
069.
070.
content = [
NSArray
arrayWithObjects:@
"ข้อมูลดอยอิน"
,@
"ข้อมูลกิ่ว"
,@
"ข้อมูลน้ำตก"
,@
"ข้อมูลน้ำตก"
,@
"ข้อมูลเกษตร"
,@
"ข้อมูลถ้ำ"
,@
"ข้อมูลแม่ยะ"
,@
"ข้อมูลออบหลวง"
,@
"ข้อมูลออบหลวง"
,@
"ข้อมูลออบหลวง"
,
nil
];
071.
072.
infoArray[0] = [
NSArray
arrayWithObjects:@
"ดอยอินทนนท์"
,@
"กิ่วแม่ปาน"
,@
"น้ำตกแม่กลาง"
,@
"น้ำตกวชิรธาร"
,
073.
@
"สถานีเกษตรหลวง"
,@
"ถ้ำบรินจินดา"
,@
"น้ำตกแม่ยะ"
,@
"ออบหลวง"
,@
"ออบหลวง"
,
nil
];
074.
075.
infoArray[1] = [
NSArray
arrayWithObjects:@
"ร้านA"
,@
"ร้านB"
,
nil
];
076.
077.
infoArray[2] = [
NSArray
arrayWithObjects:@
"เซA"
,@
"เซB"
,
nil
];
078.
079.
infoArray[3] = [
NSArray
arrayWithObjects:@
"gasA"
,@
"gasB"
,
nil
];
080.
081.
infoArray[4] = [
NSArray
arrayWithObjects:@
"busA"
,@
"busB"
,
nil
];
082.
083.
infoArray[5] = [
NSArray
arrayWithObjects:@
"policeA"
,@
"policeB"
,
nil
];
084.
085.
infoArray[6] = [
NSArray
arrayWithObjects:@
"bankA"
,@
"bankB"
,
nil
];
086.
087.
infoArray[7] = [
NSArray
arrayWithObjects:@
"fesA"
,@
"fesB"
,
nil
];
088.
089.
tableInfo = infoArray[infoRow];
090.
NSLog
(@
"row : %d"
,infoRow);
091.
[
self
GetTableDataFromWeb];
092.
093.
}
094.
095.
}
096.
097.
- (
void
)didReceiveMemoryWarning
098.
{
099.
[
super
didReceiveMemoryWarning];
100.
101.
}
102.
- (
NSInteger
)tableView:(
UITableView
*)tableView numberOfRowsInSection:(
NSInteger
)section{
103.
return
[tableInfo count];
104.
105.
}
106.
107.
108.
109.
- (
UITableViewCell
*)tableView:(
UITableView
*)tableView cellForRowAtIndexPath:(
NSIndexPath
*)indexPath{
110.
111.
static
NSString
*simpleTableIdentifier =@
"Info"
;
112.
UITableViewCell
*cell=[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
113.
if
(cell ==
nil
){
114.
cell =[[
UITableViewCell
alloc] initWithStyle:
UITableViewCellStyleDefault
reuseIdentifier:
115.
simpleTableIdentifier];
116.
}
117.
cell.textLabel.text = [tableInfo objectAtIndex:indexPath.row];
118.
cell.imageView.image =[
UIImage
imageNamed:[imageinfo objectAtIndex:indexPath.row]];
119.
120.
return
cell;
121.
}
122.
123.
-(
void
)prepareForSegue:(
UIStoryboardSegue
*)segue sender:(
id
)sender{
124.
if
([segue.identifier isEqualToString:@
"showDetail"
]){
125.
NSIndexPath
*indexPath = [
self
.sendDataTable indexPathForSelectedRow];
126.
127.
InfoViewController *destViewController = segue.destinationViewController;
128.
destViewController.infoFRow = idArray[indexPath.row];
129.
destViewController.dataName = [tableInfo objectAtIndex:indexPath.row];
130.
destViewController.dataText = [content objectAtIndex:indexPath.row];
131.
NSLog
(@
"rows ddd : %d"
,destViewController.infoFRow);
132.
133.
destViewController.hidesBottomBarWhenPushed =
YES
;
134.
135.
}
136.
137.
}