Guest User

Untitled

a guest
May 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.42 KB | None | 0 0
  1. #import "ViewC_Stuff.h"
  2. #import "Map.h"
  3. #import "Campus_TourAppDelegate.h"
  4. #import "CustomCells2.h"
  5. #import "Map.h"
  6.  
  7. @implementation ViewC_Stuff
  8. @synthesize sectionView, rowView, info, hours, number,mapLocater, viewtitle, more_Park, height, table, newMapView, c_labs_mapNum;
  9.  
  10. - (id)initWithStyle:(UITableViewStyle)style {
  11. // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
  12. if (self = [super initWithStyle:style]) {
  13. }
  14. return self;
  15. }
  16.  
  17.  
  18. - (void)setupArrays{
  19. if(sectionView == 0){
  20. if(rowView == 0){
  21. self.info = [NSArray arrayWithObjects:
  22. @"Willis Library",
  23. @"Archives",
  24. @"Circulation Department",
  25. @"Willis 24 Hr GACL",
  26. @"Digital Projects Lab",
  27. @"Government Documents Service Desk",
  28. @"General Reference Desk",
  29. @"Interlibrary Loan Hours",
  30. @"Microforms Service Desk",
  31. @"Music Library / Audio Center",
  32. @"Photocopy Office",
  33. @"Rare Book and Texana Collections",
  34. @"Reserves/Current Periodicals Room",nil];
  35.  
  36. self.hours = [NSArray arrayWithObjects:
  37. @"Sunday: 1:00 pm-2:00 am\nMonday - Thursday: 7:30 am-2:00 am\nFriday: 7:30 am-Midnight\nSaturday: 9:00 am-Midnight",
  38. @"Monday - Friday:8:00 am-5:00 pm",
  39. @"Sunday: 1:00 pm-2:00 am\nMonday - Thursday: 7:30 am-2:00 am\nFriday: 7:30 am-Midnight\nSaturday: 9:00 am-Midnight",
  40. @"Willis 24 Hr GACL\n24 Hours 7 Days a Week",
  41. @"Monday - Friday: 9:00 am-5:00 pm\nSaturday & Sunday:Closed",
  42. @"Monday - Thursday: 9:00 am-9:00 pm\nFriday: 11:00 am-4:00 pm\nSaturday: 11:00 am-4:00 pm",
  43. @"Sunday: 1:00 pm-11:00 pm\nMonday - Thursday: 8:00 am-11:00 pm\nFriday: 8:00 am-6:00 pm\nSaturday: 9:00 am-6:00 pm",
  44. @"Sunday: Closed\nMonday - Friday: 8:00 am-6:00 am\nSaturday: Closed",
  45. @"Monday - Thursday: 9:00 am-10:00 pm\nFriday & Saturday: 9:00 am-6:00 pm\nSunday: 1:00 pm-6:00 pm",
  46. @"Sunday: 1:00 pm-2:00 am\nMonday - Thursday: 7:30 am-2:00 am\nFriday: 7:30 am-Midnight\nSaturday: 9:00 am-Midnight",
  47. @"Monday - Friday: 1:30 pm-6:30 pm\nSaturday: Closed\nSunday:Closed",
  48. @"Monday - Friday: 8:00 am-Noon\nMonday - Friday: 1:00 pm-5:00 pm\nSaturday & Sunday: Closed",
  49. @"Sunday: 1:00 pm-2:00 am\nMonday - Thursday: 7:30 am-2:00 am\nFriday: 7:30 am:Midnight\nSaturday: 9:00 am-Midnight", nil];
  50.  
  51. }
  52. if(rowView == 1){
  53. self.info = [NSArray arrayWithObjects:@"Media Library",@"Science and Technology Library",@"Technical Services/Preservation",@"Research Park Library Circulation",
  54. @"Research Park Library Reference",nil];
  55.  
  56. self.hours = [NSArray arrayWithObjects:@"Sunday:4:00 pm-9:00 pm\nMonday - Thursday:7:45 am-10:00 pm\nFriday:7:45 am-6:00 pm\nSaturday:Noon-5:00 pm",
  57. @"Sunday:1:00 pm-Midnight\nMonday - Thursday:7:30 am-Midnight\nFriday:7:30 am-9:00 pm\nSaturday:9:00 am-9:00 pm",
  58. @"Monday - Friday:8:00 am-5:30 pm\nSaturday:Closed\nSunday:Closed",
  59. @"Sunday:Closed\nMonday - Thursday:9:00 am-9:45 pm\nFriday:9:00 am-4:45 pm\nSaturday:Closed",
  60. @"Monday - Thursday:9:00 am-10:00 pm\nFriday:9:00 am-5:00 pm\nSaturday:Closed\nSunday:Closed",nil];
  61.  
  62. self.c_labs_mapNum = [NSArray arrayWithObjects:[NSNumber numberWithInt:11], [NSNumber numberWithInt:33],[NSNumber numberWithInt:0],
  63. [NSNumber numberWithInt:0], [NSNumber numberWithInt:0], nil];
  64. }
  65. }
  66. if(sectionView == 1){
  67. self.info = [NSArray arrayWithObjects:@"Bruce Cafeteria", @"Champs Cafeteria", @"Clark Grill:", @"Kerr Cafeteria",@"Mean Greens",
  68. @"West Cafeteria",@"University Union", nil];
  69.  
  70. self.more_Park = [NSArray arrayWithObjects:@"Vegetarian Bar",@"BBQ Bar\nDeli Bar:",@"Baked Potato Bar\nSandwich Bar\nMexican Bar",
  71. @"Baked Potato Bar\nCajun Bar\nSabroso",@"Panini Bar\nGrill:",@"Panini Bar\nPizza Bar",
  72. @"Park Place Mkt.\nJazzman's Cart\nCafe á là Cart\nEinstein Bros. Bagels\nCampus Chat\nGrill 155\nChick-fil-A\nTaco Bell\nBruschettas\nThe Corner Store\nFreshens\nSubconnection\nJazzman's Café",nil];
  73.  
  74. self.hours = [NSArray arrayWithObjects:@"Lunch: 10:30 am - 3:00 pm\nDeli Bar: 3:00 pm - 4:30 pm\nDinner: 4:30 pm - 8:00 pm\nFriday Dinner: 4:30 pm - 7:00 pm",
  75. @"Lunch: 10:30 am - 2:30 pm\nGrill: 2:30 pm - 5:00pm\nDinner: 5:00 pm - 9:00 pm\nFriday Dinner: 5:00 pm - 7:00 pm",
  76. @"5:00 pm - 12:00 am",
  77. @"Grill: 11:00 am - 4:30\nDinner: 4:30 pm - 7:00 pm\nFriday Dinner: 4:30 pm - 7:00 pm",
  78. @"Lunch: 10:30 am - 2:30 pm\nGrill: 2:30 pm - 4:30 pm\nDinner: 4:30pm - 7:00 pm\nFriday Dinner:4:30 pm - 7:00 pm",
  79. @"Lunch: 10:30 am - 2:00 pm\nGrill: 2:00 pm - 4:30 pm\nFriday Dinner: 4:30 pm - 7:00 pm",
  80. @"check this out",nil];
  81.  
  82. self.c_labs_mapNum = [NSArray arrayWithObjects:[NSNumber numberWithInt:7], [NSNumber numberWithInt:84],[NSNumber numberWithInt:12],
  83. [NSNumber numberWithInt:37], [NSNumber numberWithInt:42], [NSNumber numberWithInt:86],
  84. [NSNumber numberWithInt:84], nil];
  85.  
  86. }
  87. }
  88.  
  89. - (void)viewWillAppear:(BOOL)animated {
  90. // NSLog(@"sectionview is %d", sectionView);
  91. // NSLog(@"title is%@", viewtitle);
  92. self.title = self.viewtitle;
  93. [self setupArrays];
  94. [table reloadData];
  95. }
  96. // Implement viewDidLoad to do additional setup after loading the view.
  97. - (void)viewDidLoad {
  98. [super viewDidLoad];
  99. }
  100.  
  101. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  102. return info.count;
  103. NSLog(@"%d", info.count);
  104. }
  105.  
  106. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  107. NSInteger temp;
  108. if(sectionView == 3){
  109. if (section == 0 ||section == 1 || section ==2 || section ==3 || section == 5){
  110. temp = 3;
  111. }else{
  112. temp = 2;
  113. }
  114. }else if(sectionView == 2){
  115. if (section == 6 || section ==9 || section ==10){
  116. temp = 4;
  117. }else{
  118. temp =5 ;
  119. }
  120. }else if(sectionView == 0){
  121. if (section ==3 || section == 4){
  122. temp = 2;
  123. }else{
  124. temp =3 ;
  125. }
  126. }else{
  127. temp = 4;
  128.  
  129. }
  130. return temp;
  131. }
  132.  
  133. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  134.  
  135. static NSString *CellIdentifier = @"Cell";
  136. CustomCells2 *cell = (CustomCells2 *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  137. if (cell == nil) {
  138. cell = [[[CustomCells2 alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
  139. }
  140. if(sectionView == 0){
  141. if(indexPath.row == 0){
  142. [cell setData:[info objectAtIndex:indexPath.section]];
  143. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  144. }
  145. if(indexPath.row == 1){
  146. [cell setData:[hours objectAtIndex:indexPath.section]];
  147. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  148. }
  149. if(indexPath.row == 2){
  150. [cell setData:@"Locate on Map"];
  151.  
  152. }
  153. }
  154. if(sectionView == 1){
  155. if(indexPath.row == 0){
  156. [cell setData:[info objectAtIndex:indexPath.section]];
  157. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  158. }
  159. if(indexPath.row == 1){
  160. [cell setData:[hours objectAtIndex:indexPath.section]];
  161. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  162. }
  163. if(indexPath.row == 2){
  164. [cell setData:[more_Park objectAtIndex:indexPath.section]];
  165. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  166. }
  167. if(indexPath.row == 3){
  168. [cell setData:@"Locate on Map"];
  169. }
  170. }
  171. if(sectionView == 2){
  172. if(indexPath.row == 0){
  173. [cell setData:[info objectAtIndex:indexPath.section]];
  174. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  175. }
  176. if(indexPath.row == 1){
  177. [cell setData:[hours objectAtIndex:indexPath.section]];
  178. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  179. }
  180. if(indexPath.row == 2){
  181. [cell setData:[NSString stringWithFormat:@"Room Number: %@",[more_Park objectAtIndex:indexPath.section]]];
  182. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  183. }
  184. if(indexPath.row == 3){
  185. [cell setData:[number objectAtIndex:indexPath.section]];
  186. }
  187. if(indexPath.row == 4){
  188. [cell setData:@"Locate on Map"];
  189. }
  190.  
  191. }
  192. if(sectionView == 3){
  193. if(indexPath.row == 0){
  194. [cell setData:[info objectAtIndex:indexPath.section]];
  195. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  196. }
  197. if(indexPath.row == 1){
  198. [cell setData:[hours objectAtIndex:indexPath.section]];
  199. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  200. }
  201. if(indexPath.row == 2){
  202. [cell setData:@"Locate on Map"];
  203. }
  204. }
  205.  
  206. // Configure the cell
  207. return cell;
  208. }
  209.  
  210. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  211. if(sectionView == 3){
  212. if(indexPath.row == 0) {
  213. NSString *text = [info objectAtIndex:indexPath.section];
  214. UIFont *font = [UIFont systemFontOfSize:16];
  215. CGSize constraint = CGSizeMake(300,4000);
  216. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  217. return size.height+30;
  218. }else if(indexPath.row == 1) {
  219. NSString *text = [hours objectAtIndex:indexPath.section];
  220. UIFont *font = [UIFont systemFontOfSize:16];
  221. CGSize constraint = CGSizeMake(300,4000);
  222. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  223. return size.height+30;
  224. }else{
  225. return 50;
  226. }
  227.  
  228. }else if(sectionView == 2){
  229. if(indexPath.row == 0) {
  230. NSString *text = [info objectAtIndex:indexPath.section];
  231. UIFont *font = [UIFont systemFontOfSize:16];
  232. CGSize constraint = CGSizeMake(300,4000);
  233. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  234. return size.height+30;
  235. }else if(indexPath.row == 1) {
  236. NSString *text = [hours objectAtIndex:indexPath.section];
  237. UIFont *font = [UIFont systemFontOfSize:16];
  238. CGSize constraint = CGSizeMake(300,4000);
  239. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  240. return size.height+30;
  241. }else{
  242. return 50;
  243. }
  244.  
  245. }else if(sectionView == 1){
  246. if(indexPath.row == 0){
  247. NSString *text = [info objectAtIndex:indexPath.section];
  248. UIFont *font = [UIFont systemFontOfSize:16];
  249. CGSize constraint = CGSizeMake(300,4000);
  250. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  251. return size.height+30;
  252. }else if(indexPath.row == 1){
  253. NSString *text = [hours objectAtIndex:indexPath.section];
  254. UIFont *font = [UIFont systemFontOfSize:16];
  255. CGSize constraint = CGSizeMake(300,4000);
  256. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  257. return size.height+30;
  258. }else if(indexPath.row == 2){
  259. NSString *text = [more_Park objectAtIndex:indexPath.section];
  260. UIFont *font = [UIFont systemFontOfSize:16];
  261. CGSize constraint = CGSizeMake(300,4000);
  262. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  263. return size.height+30;
  264. }
  265. return 50;
  266.  
  267. }else{
  268. if(indexPath.row == 0) {
  269. NSString *text = [info objectAtIndex:indexPath.section];
  270. UIFont *font = [UIFont systemFontOfSize:16];
  271. CGSize constraint = CGSizeMake(300,4000);
  272. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  273. return size.height+30;
  274. }else if(indexPath.row == 1) {
  275. NSString *text = [hours objectAtIndex:indexPath.section];
  276. UIFont *font = [UIFont systemFontOfSize:16];
  277. CGSize constraint = CGSizeMake(300,4000);
  278. CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  279. return size.height+30;
  280. }else{
  281. return 50;
  282. }
  283. }
  284. }
  285.  
  286. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  287. Campus_TourAppDelegate *appdelegate = (Campus_TourAppDelegate *)[[UIApplication sharedApplication] delegate];//create a delegate object
  288. NSLog(@"sectionvew %d rowview %d", sectionView, rowView);
  289. if (newMapView == nil){
  290. Map *nView =[[Map alloc] initWithNibName:@"Map" bundle:nil];
  291. self.newMapView = nView;
  292. [nView release];
  293. }
  294.  
  295. /////parking lots
  296. if(sectionView == 3 && indexPath.row == 2){
  297. if(indexPath.section == 0){
  298. newMapView.load_view = 2;
  299. }
  300. if(indexPath.section == 1){
  301. newMapView.load_view = 3;
  302. }
  303. if(indexPath.section == 2){
  304. newMapView.load_view = 5;
  305. }
  306. if(indexPath.section == 3){
  307. newMapView.load_view = 4;
  308. }
  309. if(indexPath.section == 5){
  310. newMapView.load_view = 6;
  311. }
  312. [self.navigationController pushViewController:newMapView animated:YES];
  313. }
  314.  
  315. //////////cafeterias////////
  316. if(sectionView == 1 && indexPath.row == 3){
  317. newMapView.building = [[c_labs_mapNum objectAtIndex:indexPath.section] intValue];
  318. appdelegate.first = NO;
  319. newMapView.load_view = 0;
  320. [self.navigationController pushViewController:newMapView animated:YES];
  321. }
  322.  
  323. //////////computer labs////////
  324. ////call people
  325. if(sectionView ==2 && indexPath.row == 3){
  326. // NSURL *url = [NSURL URLWithString:[number objectAtIndex:indexPath.section]];
  327. // [[UIApplication sharedApplication] openURL:url];
  328. NSString *temp = [NSString stringWithFormat:@"tel:%@", [number objectAtIndex:indexPath.section]];
  329. NSURL *phoneNumberURL = [NSURL URLWithString:temp];
  330. [[UIApplication sharedApplication] openURL:phoneNumberURL];
  331. }
  332.  
  333. ////find on map
  334. if(sectionView == 2 && indexPath.row == 4){
  335. newMapView.building = [[c_labs_mapNum objectAtIndex:indexPath.section] intValue];
  336. appdelegate.first = NO;
  337. newMapView.load_view = 0;
  338. [self.navigationController pushViewController:newMapView animated:YES];
  339. }
  340.  
  341. //////////libraries
  342. /*
  343. if(sectionView == 0 && rowView == 0){
  344. appdelegate.building = [[c_labs_mapNum objectAtIndex:indexPath.section] intValue];
  345. appdelegate.isNew = NO;
  346. newMapView.load_view = 0;
  347. [self.navigationController pushViewController:newMapView animated:YES];
  348. }*/
  349. if(sectionView == 0 && rowView == 1){
  350. newMapView.building = [[c_labs_mapNum objectAtIndex:indexPath.section] intValue];
  351. // NSLog(@"app building %d", appdelegate.building);
  352. appdelegate.first = NO;
  353. newMapView.load_view = 0;
  354. [self.navigationController pushViewController:newMapView animated:YES];
  355. }
  356.  
  357. }
  358.  
  359. - (void)didReceiveMemoryWarning {
  360. NSLog(@"memory warning viewc_stuff.m");
  361. [super didReceiveMemoryWarning];
  362. }
  363.  
  364. - (void)dealloc {
  365. [number release];
  366. [c_labs_mapNum release];
  367. [table release];
  368. [info release];
  369. [hours release];
  370. [more_Park release];
  371. [newMapView release];
  372. [viewtitle release];
  373. [super dealloc];
  374. }
  375.  
  376.  
  377. @end
Add Comment
Please, Sign In to add comment