Guest User

Untitled

a guest
Jun 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  2. return 1;
  3. }
  4.  
  5. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  6. return [array1 count];
  7. }
  8.  
  9. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}
  10.  
  11. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  12. if (tableView == _displayThemes) {
  13. return 1;
  14. } else {
  15. return 1;
  16. }
  17. }
  18.  
  19. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  20. if(tableView==_displayThemes) {
  21. return 1;
  22. } else {
  23. return 5;
  24. }
  25. }
  26.  
  27. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  28. static NSString *CellIdentifier = @"Cell";
  29. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  30.  
  31. if (!cell) {
  32. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  33. }
  34.  
  35. if (tableView == _displayThemes) {
  36. cell.textLabel.text = [displaytheme objectAtIndex:indexPath.row];
  37. return cell;
  38. } else {
  39. cell.textLabel.text = [fontlist objectAtIndex:indexPath.row];
  40. return cell;
  41. }
  42. }
  43.  
  44.  
  45. - (IBAction)fontButton:(id)sender {
  46. _fontList = [[UITableView alloc]init];
  47. [self.view addSubview:_fontList];
  48. [UIView animateWithDuration:1.5
  49. delay:0
  50. options: UIViewAnimationOptionTransitionCurlUp
  51. animations:^{
  52. _fontList.fram e= CGRectMake(0,800,320,200);
  53. }
  54. completion:^(BOOL finished){
  55. _fontList.frame = CGRectMake(0,280,320,200);
  56. }];
  57.  
  58. [_fontList reloadData];
  59. }
  60.  
  61. - (IBAction)button:(id)sender {
  62. _displayThemes = [[UITableView alloc]init];
  63. [self.view addSubview:_displayThemes];
  64. [UIView animateWithDuration:1.5
  65. delay:0
  66. options: UIViewAnimationOptionTransitionCurlUp
  67. animations:^{
  68. _displayThemes.frame=CGRectMake(0,800,320,200);
  69. }
  70. completion:^(BOOL finished){
  71. _displayThemes.frame=CGRectMake(0,280,320,200);
  72. }];
  73. }
  74.  
  75. myTableView1.dataSource = self;
  76. ...
  77.  
  78. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  79. if (tableView == myTableView1) {
  80. // your code 1
  81. }
  82. else
  83. if (tableView == myTableView2) {
  84. // your code 2
  85. }
  86. else
  87. if (tableView == myTableView3) {
  88. // your code 3
  89. }
  90. }
  91.  
  92. - (void) sliderChanged:(UISlider*)sender{
  93. UISlider *slider = (UISlider*)sender;
  94. [[UIScreen mainScreen] setBrightness:slider.value];
  95. }
  96.  
  97. slider.tag = 1;
  98. [cell addSubview:slider];
  99.  
  100.  
  101. ...
  102. // when you need..
  103. indexPath = [NSIndexPath indexPathForRow:myRow inSection:mySecion];
  104. UISlider* slider = (UISlider*) [[self.tableView cellForRowAtIndexPath:indexPath] viewWithTag:1];
  105.  
  106. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  107. {
  108. if (tableView == self.tableView1)
  109. {
  110. return 1;
  111. }
  112.  
  113. if (tableView == self.tableView2)
  114. {
  115. return 1;
  116. }
  117.  
  118. if (tableView == self.tableView3)
  119. {
  120. return 1;
  121. }
  122. }
  123.  
  124. -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
  125. {
  126. if (tableView == self.tableView1)
  127. {
  128. static NSString *CellIdentifier1 = @"cellForTable1";
  129.  
  130. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
  131.  
  132. if (!cell)
  133. {
  134. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1];
  135. }
  136.  
  137. cell.textLabel.text = [NSString stringWithFormat: @"table1: %d.%d", indexPath.section, indexPath.row];
  138.  
  139. return cell;
  140. }
  141.  
  142. if (tableView == self.tableView2)
  143. {
  144. static NSString *CellIdentifier2 = @"cellForTable2";
  145.  
  146. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
  147.  
  148. if (!cell)
  149. {
  150. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
  151. }
  152.  
  153. cell.textLabel.text = [NSString stringWithFormat: @"table2: %d.%d", indexPath.section, indexPath.row];
  154.  
  155. return cell;
  156. }
  157.  
  158. if (tableView == self.tableView1)
  159. {
  160. static NSString *CellIdentifier3 = @"cellForTable3";
  161.  
  162. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier3];
  163.  
  164. if (!cell)
  165. {
  166. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier3];
  167. }
  168.  
  169. cell.textLabel.text = [NSString stringWithFormat: @"table3: %d.%d", indexPath.section, indexPath.row];
  170.  
  171. return cell;
  172. }
  173. }
  174.  
  175. //add tag in tableView .
  176. myTable1.tag = 200;
  177. myTable2.tag = 201;
  178. myTable3.tag = 202;
  179. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  180. {
  181. if (tableView.tag == 200)
  182. {
  183. return 1;
  184. }
  185. if (tableView.tag == 201)
  186. {
  187. return 1;
  188. }
  189. if (tableView.tag == 202)
  190. {
  191. return 1;
  192. }
  193.  
  194.  
  195. }
  196.  
  197. public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  198. if((tableView1 != nil) && (tableView == tableView1)) {
  199. return Items1.count
  200. }
  201. else if((tableView2 != nil) && (tableView == tableView2)) {
  202. return Items2.count
  203. }
  204. else if((tableView3 != nil) && (tableView == tableView3)) {
  205. return Items3.count
  206. }
  207. else {
  208. return 0
  209. }
  210. }
  211.  
  212. public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  213. if tableView == tableView1
  214. {
  215. // your code
  216. }
  217. else if tableView == tableView2 {
  218. // your code
  219. }
  220.  
  221. else {
  222. return 0
  223. }
  224. }
  225. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  226. if tableView == tableView1
  227. {
  228. // your code
  229. }
  230. else if tableView == tableView2 {
  231. // your code
  232. }
  233.  
  234. else {
  235. return 0
  236. }
  237. }
Add Comment
Please, Sign In to add comment