PageRenderTime 49ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/Classes/UVSuggestionDetailsViewController.m

https://github.com/appsocial/uservoice-iphone-sdk
Objective C | 570 lines | 458 code | 84 blank | 28 comment | 41 complexity | 66a98764d1dfddeccbf1c9fc1d6ebf41 MD5 | raw file
  1. //
  2. // UVSuggestionDetailsViewController.m
  3. // UserVoice
  4. //
  5. // Created by UserVoice on 10/29/09.
  6. // Copyright 2009 UserVoice Inc. All rights reserved.
  7. //
  8. #import <QuartzCore/QuartzCore.h>
  9. #import "UVSuggestionDetailsViewController.h"
  10. #import "UVCommentListViewController.h"
  11. #import "UVProfileViewController.h"
  12. #import "UVStyleSheet.h"
  13. #import "UVSession.h"
  14. #import "UVSuggestion.h"
  15. #import "UVResponseViewController.h"
  16. #import "UVSuggestionChickletView.h"
  17. #import "UVFooterView.h"
  18. #import "UVUserButton.h"
  19. #import "UVUser.h"
  20. #import "UVClientConfig.h"
  21. #import "UVSignInViewController.h"
  22. #define CHICKLET_TAG 1001
  23. #define VOTE_SEGMENTS_TAG 1002
  24. #define VOTE_LABEL_TAG 1003
  25. #define NO_VOTE_LABEL_TAG 1004
  26. #define UV_SUGGESTION_DETAILS_SECTION_HEADER 5
  27. #define UV_SUGGESTION_DETAILS_SECTION_VOTE 0
  28. #define UV_SUGGESTION_DETAILS_SECTION_BODY 1
  29. #define UV_SUGGESTION_DETAILS_SECTION_COMMENTS 2
  30. #define UV_SUGGESTION_DETAILS_SECTION_CREATOR 3
  31. @implementation UVSuggestionDetailsViewController
  32. @synthesize suggestion, innerTableView;
  33. - (id)initWithSuggestion:(UVSuggestion *)theSuggestion {
  34. if (self = [super init]) {
  35. self.suggestion = theSuggestion;
  36. }
  37. return self;
  38. }
  39. - (NSString *)backButtonTitle {
  40. return @"Idea";
  41. }
  42. - (void)voteSegmentChanged:(id)sender {
  43. UISegmentedControl *segments = (UISegmentedControl *)sender;
  44. if (segments.selectedSegmentIndex != self.suggestion.votesFor) {
  45. [self showActivityIndicator];
  46. // no longer supported so remove from supportedSuggestions
  47. // also should decrement counters
  48. if (segments.selectedSegmentIndex==0 && [[UVSession currentSession].user.supportedSuggestions count]!=0) {
  49. NSInteger index = 0;
  50. NSInteger suggestionIndex = 0;
  51. for (UVSuggestion *aSuggestion in [UVSession currentSession].user.supportedSuggestions) {
  52. if (aSuggestion.suggestionId == self.suggestion.suggestionId)
  53. suggestionIndex = index;
  54. index++;
  55. }
  56. NSLog(@"Removing sugggestion index %d from %d supported suggestions", suggestionIndex,
  57. [[UVSession currentSession].user.supportedSuggestions count]);
  58. [[UVSession currentSession].user.supportedSuggestions removeObjectAtIndex:suggestionIndex];
  59. [UVSession currentSession].user.supportedSuggestionsCount -= 1;
  60. } else if (self.suggestion.votesFor == 0) {
  61. NSLog(@"Adding new supported suggestion");
  62. // add if not there
  63. [[UVSession currentSession].user.supportedSuggestions addObject:self.suggestion];
  64. [UVSession currentSession].user.supportedSuggestionsCount += 1;
  65. }
  66. self.suggestion.votesFor = segments.selectedSegmentIndex;
  67. [self.suggestion vote:segments.selectedSegmentIndex delegate:self];
  68. }
  69. }
  70. - (void)didVoteForSuggestion:(UVSuggestion *)theSuggestion {
  71. NSLog(@"Voted for suggestion: %@", theSuggestion);
  72. [UVSession currentSession].clientConfig.forum.currentTopic.votesRemaining = theSuggestion.votesRemaining;
  73. [UVSession currentSession].clientConfig.forum.currentTopic.suggestionsNeedReload = YES;
  74. self.suggestion = theSuggestion;
  75. [self.innerTableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)]
  76. withRowAnimation:UITableViewRowAnimationFade];
  77. UVSuggestionChickletView *chicklet = (UVSuggestionChickletView *)[self.view viewWithTag:CHICKLET_TAG];
  78. if (self.suggestion.status) {
  79. [chicklet updateWithSuggestion:self.suggestion style:UVSuggestionChickletStyleDetail];
  80. } else {
  81. [chicklet updateWithSuggestion:self.suggestion style:UVSuggestionChickletStyleEmpty];
  82. }
  83. [self hideActivityIndicator];
  84. }
  85. - (void)promptForFlag {
  86. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Flag Idea?"
  87. message:@"Are you sure you want to flag this idea as inappropriate?"
  88. delegate:self
  89. cancelButtonTitle:@"Cancel"
  90. otherButtonTitles:@"Flag", nil];
  91. [alert show];
  92. [alert release];
  93. }
  94. - (void)didFlagSuggestion:(UVSuggestion *)theSuggestion {
  95. [self hideActivityIndicator];
  96. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success"
  97. message:@"You have successfully flagged this idea as inappropriate."
  98. delegate:nil
  99. cancelButtonTitle:nil
  100. otherButtonTitles:@"OK", nil];
  101. [alert show];
  102. [alert release];
  103. }
  104. // Calculates the height of the text.
  105. - (CGSize)textSize
  106. {
  107. CGFloat screenWidth = [UVClientConfig getScreenWidth];
  108. // Probably doesn't matter, but we might want to cache this since we call it twice.
  109. return [self.suggestion.text
  110. sizeWithFont:[UIFont systemFontOfSize:13]
  111. constrainedToSize:CGSizeMake((screenWidth-20), 10000)
  112. lineBreakMode:UILineBreakModeWordWrap];
  113. }
  114. // Calculates the height of the title.
  115. - (CGSize)titleSize
  116. {
  117. CGFloat screenWidth = [UVClientConfig getScreenWidth];
  118. // Probably doesn't matter, but we might want to cache this since we call it twice.
  119. return [self.suggestion.title
  120. sizeWithFont:[UIFont boldSystemFontOfSize:18]
  121. constrainedToSize:CGSizeMake((screenWidth-85), 10000)
  122. lineBreakMode:UILineBreakModeWordWrap];
  123. }
  124. - (void)setVoteLabelTextAndColorForLabel:(UILabel *)label {
  125. NSInteger votesRemaining = [UVSession currentSession].clientConfig.forum.currentTopic.votesRemaining;
  126. [self setVoteLabelTextAndColorForVotesRemaining:votesRemaining label:label];
  127. }
  128. - (NSString *)postDateString {
  129. static NSDateFormatter* dateFormatter = nil;
  130. if (!dateFormatter) {
  131. dateFormatter = [[NSDateFormatter alloc] init];
  132. [dateFormatter setDateFormat:@"MMMM dd, yyyy"];
  133. }
  134. return [dateFormatter stringFromDate:self.suggestion.createdAt];
  135. }
  136. #pragma mark ===== UIAlertViewDelegate Methods =====
  137. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  138. if (buttonIndex != alertView.cancelButtonIndex) {
  139. [self showActivityIndicator];
  140. [self.suggestion flag:@"inappropriate" delegate:self];
  141. }
  142. }
  143. #pragma mark ===== table cells =====
  144. - (void)initCellForVote:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath
  145. {
  146. [self removeBackgroundFromCell:cell];
  147. CGFloat screenWidth = [UVClientConfig getScreenWidth];
  148. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  149. UIView *bg = [[UILabel alloc] initWithFrame:CGRectMake(-10, 0, screenWidth, 72)];
  150. bg.backgroundColor = [UVStyleSheet lightBgColor];
  151. [cell.contentView addSubview:bg];
  152. [bg release];
  153. if ([suggestion.status isEqualToString:@"completed"]) {
  154. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, (screenWidth-20), 44)];
  155. label.tag = NO_VOTE_LABEL_TAG;
  156. label.numberOfLines = 2;
  157. label.opaque = YES;
  158. label.backgroundColor = [UVStyleSheet lightBgColor];
  159. label.textAlignment = UITextAlignmentCenter;
  160. label.font = [UIFont systemFontOfSize:14];
  161. label.text = [NSString stringWithFormat:
  162. @"Voting for this suggestion is now closed and your %d %@ been returned to you",
  163. self.suggestion.votesFor,
  164. self.suggestion.votesFor == 1 ? @"vote has" : @"votes have"];
  165. label.textColor = [UVStyleSheet dimBlueColor];
  166. [cell.contentView addSubview:label];
  167. [label release];
  168. } else {
  169. NSArray *items = [NSArray arrayWithObjects:@"0 votes", @"1 vote", @"2 votes", @"3 votes", nil];
  170. UISegmentedControl *segments = [[UISegmentedControl alloc] initWithItems:items];
  171. segments.tag = VOTE_SEGMENTS_TAG;
  172. segments.frame = CGRectMake(0, 0, (screenWidth-20), 44);
  173. [segments addTarget:self action:@selector(voteSegmentChanged:) forControlEvents:UIControlEventValueChanged];
  174. UILabel *label;
  175. if ([UVSession currentSession].user != nil) {
  176. label = [[UILabel alloc] initWithFrame:CGRectMake(0, 49, (screenWidth-20), 14)];
  177. } else {
  178. [segments setEnabled:NO];
  179. label = [[UILabel alloc] initWithFrame:CGRectMake(0, 49, (screenWidth-20), 17)];
  180. }
  181. [cell.contentView addSubview:segments];
  182. [segments release];
  183. label.opaque = YES;
  184. label.backgroundColor = [UVStyleSheet lightBgColor];
  185. label.tag = VOTE_LABEL_TAG;
  186. label.numberOfLines = 0;
  187. label.textAlignment = UITextAlignmentCenter;
  188. label.font = [UIFont systemFontOfSize:12];
  189. [cell.contentView addSubview:label];
  190. [label release];
  191. }
  192. }
  193. - (void)customizeCellForVote:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath {
  194. if ([UVSession currentSession].user != nil) {
  195. UISegmentedControl *segments = (UISegmentedControl *)[cell.contentView viewWithTag:VOTE_SEGMENTS_TAG];
  196. segments.selectedSegmentIndex = self.suggestion.votesFor;
  197. NSInteger votesRemaining = [UVSession currentSession].clientConfig.forum.currentTopic.votesRemaining;
  198. for (int i = 0; i < segments.numberOfSegments; i++) {
  199. NSInteger votesNeeded = i - self.suggestion.votesFor;
  200. BOOL enabled = votesNeeded <= votesRemaining;
  201. [segments setEnabled:enabled forSegmentAtIndex:i];
  202. }
  203. UILabel *label = (UILabel *)[cell.contentView viewWithTag:VOTE_LABEL_TAG];
  204. if (label)
  205. [self setVoteLabelTextAndColorForLabel:label];
  206. }
  207. }
  208. - (void)initCellForBody:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath
  209. {
  210. [self removeBackgroundFromCell:cell];
  211. CGFloat screenWidth = [UVClientConfig getScreenWidth];
  212. NSInteger height = [self textSize].height > 0 ? [self textSize].height + 10 : 0;
  213. UIView *bg = [[UILabel alloc] initWithFrame:CGRectMake(-10, 0, screenWidth, height)];
  214. bg.backgroundColor = [UVStyleSheet lightBgColor];
  215. [cell.contentView addSubview:bg];
  216. [bg release];
  217. // The default margins are too large for the body, so we're using our own label.
  218. UILabel *body = [[[UILabel alloc] initWithFrame:CGRectMake(0, -3, (screenWidth-20), [self textSize].height)] autorelease];
  219. body.text = self.suggestion.text;
  220. body.font = [UIFont systemFontOfSize:13];
  221. body.lineBreakMode = UILineBreakModeWordWrap;
  222. body.numberOfLines = 0;
  223. body.backgroundColor = [UIColor clearColor];
  224. [cell.contentView addSubview:body];
  225. }
  226. - (void)customizeCellForStatus:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath {
  227. NSString *status = suggestion.status ? suggestion.status : @"N/A";
  228. cell.textLabel.text = [NSString stringWithFormat:@"Status: %@", [status capitalizedString]];
  229. //cell.textLabel.textColor = self.suggestion.statusColor;
  230. if (self.suggestion.responseText) {
  231. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  232. } else {
  233. cell.accessoryType = UITableViewCellAccessoryNone;
  234. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  235. }
  236. }
  237. - (void)customizeCellForComments:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath {
  238. cell.textLabel.text = [NSString stringWithFormat:(self.suggestion.commentsCount == 1 ? @"%d Comment" : @"%d Comments"), self.suggestion.commentsCount];
  239. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  240. cell.selectionStyle = UITableViewCellSelectionStyleBlue;
  241. }
  242. - (void)customizeCellForFlag:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath {
  243. cell.textLabel.text = @"Flag as inappropriate";
  244. }
  245. - (void)initCellForCreator:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath
  246. {
  247. [self removeBackgroundFromCell:cell];
  248. CGFloat screenWidth = [UVClientConfig getScreenWidth];
  249. UIView *bg = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, (screenWidth-20), 75)];
  250. bg.backgroundColor = [UVStyleSheet lightBgColor];
  251. [cell.contentView addSubview:bg];
  252. [bg release];
  253. // Name label
  254. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 13, 85, 16)];
  255. label.backgroundColor = [UIColor clearColor];
  256. label.textColor = [UIColor grayColor];
  257. label.textAlignment = UITextAlignmentRight;
  258. label.font = [UIFont boldSystemFontOfSize:13];
  259. label.text = @"Created by";
  260. [cell.contentView addSubview:label];
  261. [label release];
  262. // Name
  263. UVUserButton *nameButton = [UVUserButton buttonWithUserId:self.suggestion.creatorId
  264. name:self.suggestion.creatorName
  265. controller:self
  266. origin:CGPointMake(95, 13)
  267. maxWidth:205
  268. font:[UIFont boldSystemFontOfSize:13]
  269. color:[UVStyleSheet dimBlueColor]];
  270. [cell.contentView addSubview:nameButton];
  271. // Date label
  272. label = [[UILabel alloc] initWithFrame:CGRectMake(0, 43, 85, 13)];
  273. label.backgroundColor = [UIColor clearColor];
  274. label.textColor = [UIColor grayColor];
  275. label.textAlignment = UITextAlignmentRight;
  276. label.font = [UIFont boldSystemFontOfSize:13];
  277. label.text = @"Post date";
  278. [cell.contentView addSubview:label];
  279. [label release];
  280. // Date
  281. label = [[UILabel alloc] initWithFrame:CGRectMake(95, 43, 205, 14)];
  282. label.backgroundColor = [UIColor clearColor];
  283. label.textColor = [UIColor blackColor];
  284. label.textAlignment = UITextAlignmentLeft;
  285. label.font = [UIFont systemFontOfSize:13];
  286. label.text = [self postDateString];
  287. [cell.contentView addSubview:label];
  288. [label release];
  289. }
  290. #pragma mark ===== UITableViewDataSource Methods =====
  291. - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  292. NSString *identifier = @"";
  293. BOOL selectable = YES;
  294. switch (indexPath.section) {
  295. case UV_SUGGESTION_DETAILS_SECTION_VOTE:
  296. identifier = @"Vote";
  297. if ([UVSession currentSession].user!=nil)
  298. selectable = NO;
  299. break;
  300. case UV_SUGGESTION_DETAILS_SECTION_BODY:
  301. identifier = @"Body";
  302. selectable = NO;
  303. break;
  304. case UV_SUGGESTION_DETAILS_SECTION_COMMENTS:
  305. switch (indexPath.row) {
  306. case 0:
  307. identifier = @"Status";
  308. break;
  309. case 1:
  310. identifier = @"Comments";
  311. break;
  312. case 2:
  313. identifier = @"Flag";
  314. break;
  315. }
  316. break;
  317. case UV_SUGGESTION_DETAILS_SECTION_CREATOR:
  318. identifier = @"Creator";
  319. selectable = NO;
  320. break;
  321. }
  322. NSLog(@"IDENTIFIER: %@", identifier);
  323. return [self createCellForIdentifier:identifier
  324. tableView:theTableView
  325. indexPath:indexPath
  326. style:UITableViewCellStyleDefault
  327. selectable:selectable];
  328. }
  329. - (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView {
  330. return 4;
  331. }
  332. - (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section {
  333. switch (section) {
  334. case UV_SUGGESTION_DETAILS_SECTION_COMMENTS:
  335. return 3;
  336. break;
  337. default:
  338. return 1;
  339. }
  340. }
  341. #pragma mark ===== UITableViewDelegate Methods =====
  342. - (CGFloat)tableView:(UITableView *)theTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  343. switch (indexPath.section) {
  344. case UV_SUGGESTION_DETAILS_SECTION_VOTE:
  345. return 73;
  346. break;
  347. case UV_SUGGESTION_DETAILS_SECTION_BODY:
  348. return [self textSize].height > 0 ? [self textSize].height + 10 : 0;
  349. break;
  350. case UV_SUGGESTION_DETAILS_SECTION_CREATOR:
  351. return 71;
  352. break;
  353. default:
  354. return 44;
  355. }
  356. }
  357. - (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  358. UIViewController *next = nil;
  359. switch (indexPath.section) {
  360. case UV_SUGGESTION_DETAILS_SECTION_VOTE: {
  361. if ([UVSession currentSession].user==nil) {
  362. UVSignInViewController *next = [[UVSignInViewController alloc] init];
  363. [self.navigationController pushViewController:next animated:YES];
  364. [next release];
  365. }
  366. break;
  367. }
  368. case UV_SUGGESTION_DETAILS_SECTION_COMMENTS: {
  369. switch (indexPath.row) {
  370. case 0: // status
  371. if (self.suggestion.responseText) {
  372. next = [[UVResponseViewController alloc] initWithSuggestion:self.suggestion];
  373. }
  374. break;
  375. case 1: // comments
  376. next = [[UVCommentListViewController alloc] initWithSuggestion:self.suggestion];
  377. break;
  378. case 2: // flag
  379. [self promptForFlag];
  380. break;
  381. }
  382. break;
  383. }
  384. default:
  385. break;
  386. }
  387. [theTableView deselectRowAtIndexPath:indexPath animated:YES];
  388. if (next) {
  389. [self.navigationController pushViewController:next animated:YES];
  390. [next release];
  391. }
  392. }
  393. #pragma mark ===== Basic View Methods =====
  394. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  395. - (void)loadView {
  396. [super loadView];
  397. self.navigationItem.title = self.suggestion.title;
  398. CGRect frame = [self contentFrame];
  399. UIView *contentView = [[UIView alloc] initWithFrame:frame];
  400. CGFloat screenWidth = [UVClientConfig getScreenWidth];
  401. CGFloat screenHeight = [UVClientConfig getScreenHeight];
  402. UITableView *theTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight-44) style:UITableViewStyleGrouped];
  403. theTableView.sectionHeaderHeight = 0.0;
  404. theTableView.sectionFooterHeight = 0.0;
  405. theTableView.contentInset = UIEdgeInsetsMake(-10, 0, 0, 0);
  406. NSInteger height = MAX([self titleSize].height + 347, 383);
  407. height += [self textSize].height > 0 ? [self textSize].height + 10 : 0;
  408. UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, height)];
  409. headerView.backgroundColor = [UIColor clearColor];
  410. UIImage *shadow = [UIImage imageNamed:@"dropshadow_top_20.png"];
  411. CGFloat widthScale = screenWidth / shadow.size.width; // horizontal scaling factor to expand shadow image
  412. UIImageView *shadowView = [[UIImageView alloc] initWithImage:shadow];
  413. shadowView.transform = CGAffineTransformMakeScale(widthScale, 1.0); // rescale the shadow
  414. shadowView.center = CGPointMake(screenWidth/2, shadowView.center.y); // recenter the upscaled shadow
  415. [headerView addSubview:shadowView];
  416. [shadowView release];
  417. UIView *bg = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, screenWidth, height)];
  418. bg.backgroundColor = [UVStyleSheet lightBgColor];
  419. [headerView addSubview:bg];
  420. [bg release];
  421. // Votes
  422. UVSuggestionChickletView *chicklet = [UVSuggestionChickletView suggestionChickletViewWithOrigin:CGPointMake(10, 20)];
  423. chicklet.tag = CHICKLET_TAG;
  424. [headerView addSubview:chicklet];
  425. // Title
  426. CGSize titleSize = [self titleSize];
  427. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(75, 20, titleSize.width, titleSize.height)];
  428. label.text = self.suggestion.title;
  429. label.font = [UIFont boldSystemFontOfSize:18.0];
  430. label.textAlignment = UITextAlignmentLeft;
  431. label.numberOfLines = 0;
  432. label.backgroundColor = [UIColor clearColor];
  433. [headerView addSubview:label];
  434. [label release];
  435. // Category
  436. label = [[UILabel alloc] initWithFrame:CGRectMake(75, titleSize.height + 30, titleSize.width, 11)];
  437. label.lineBreakMode = UILineBreakModeTailTruncation;
  438. label.numberOfLines = 1;
  439. label.font = [UIFont boldSystemFontOfSize:11];
  440. label.textColor = [UIColor darkGrayColor];
  441. label.backgroundColor = [UIColor clearColor];
  442. label.text = self.suggestion.categoryString;
  443. [label sizeToFit];
  444. [headerView addSubview:label];
  445. [label release];
  446. NSInteger yOffset = MAX([self titleSize].height + 55, 90);
  447. UITableView *theInnerTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, yOffset, screenWidth, MAX([self titleSize].height + 273, 313))
  448. style:UITableViewStyleGrouped];
  449. theInnerTableView.dataSource = self;
  450. theInnerTableView.delegate = self;
  451. theInnerTableView.sectionHeaderHeight = 0.0;
  452. theInnerTableView.sectionFooterHeight = 3.0;
  453. theInnerTableView.backgroundColor = [UVStyleSheet lightBgColor];
  454. self.innerTableView = theInnerTableView;
  455. [headerView addSubview:theInnerTableView];
  456. theTableView.tableHeaderView = headerView;
  457. theTableView.tableFooterView = [UVFooterView footerViewForController:self];
  458. [contentView addSubview:theTableView];
  459. self.tableView = theTableView;
  460. [theTableView release];
  461. self.view = contentView;
  462. [contentView release];
  463. }
  464. - (void)viewWillAppear:(BOOL)animated {
  465. [self.tableView reloadData];
  466. [self.innerTableView reloadData];
  467. UVSuggestionChickletView *chicklet = (UVSuggestionChickletView *)[self.view viewWithTag:CHICKLET_TAG];
  468. if (self.suggestion.status) {
  469. [chicklet updateWithSuggestion:self.suggestion style:UVSuggestionChickletStyleDetail];
  470. } else {
  471. [chicklet updateWithSuggestion:self.suggestion style:UVSuggestionChickletStyleEmpty];
  472. }
  473. }
  474. - (void)didReceiveMemoryWarning {
  475. // Releases the view if it doesn't have a superview.
  476. [super didReceiveMemoryWarning];
  477. // Release any cached data, images, etc that aren't in use.
  478. }
  479. - (void)viewDidUnload {
  480. // Release any retained subviews of the main view.
  481. // e.g. self.myOutlet = nil;
  482. }
  483. - (void)dealloc {
  484. [super dealloc];
  485. }
  486. @end