Multiple UITableview in Single Viewcontroller

后端 未结 5 1896
無奈伤痛
無奈伤痛 2020-12-09 10:16

I have a viewcontroller in that i want to show 3 tableviews(because the content and the table properties are different). How do i add these delegat

5条回答
  •  萌比男神i
    2020-12-09 11:16

    It will be the same as you do it with one table view, but you should check which tableview is currently using.

    myTableView1.dataSource = self;
    ...
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      if (tableView == myTableView1) {
        // your code 1
      }
      else 
      if (tableView == myTableView2) {
          // your code 2
      }
      else 
      if (tableView == myTableView3) {
          // your code 3
      }
    }
    

    Edit:

    About brightness:

    How to change brightness in iOS 5 app?

    And about UISlider it has minimunValue and maximumValue properties.

    - (void) sliderChanged:(UISlider*)sender{
        UISlider *slider = (UISlider*)sender;
        [[UIScreen mainScreen] setBrightness:slider.value];
    }
    

    Edit:

    slider.tag = 1;
    [cell addSubview:slider];
    
    
    ...
    // when you need..
    indexPath = [NSIndexPath indexPathForRow:myRow inSection:mySecion];
    UISlider* slider = (UISlider*) [[self.tableView cellForRowAtIndexPath:indexPath] viewWithTag:1];
    

提交回复
热议问题