小编use*_*431的帖子

如何通过标签从UIView获取某个子视图

我是Objective-C的菜鸟,我有一个问题.

我有一个UILabel对象,我用这段代码添加到一个UIView:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,10,self.view.frame.size.width-15-70, 30)];
label.tag = 1;
label.font = [PublicObject fontTexts:17];
label.textAlignment = NSTextAlignmentRight;
label.textColor = [UIColor whiteColor];
[cell setBackgroundColor:[UIColor clearColor]];

 UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
 view.backgroundColor = [PublicObject colorWithHexString:@"cd4110"];
 label.text = [filterData objectAtIndex:indexPath.row];
 view addSubview:label];
Run Code Online (Sandbox Code Playgroud)

现在我希望在我的视图中获得一个子视图,其中此子视图具有tag = 1并将其保存在另一个对象上,如下所示:

UILabel *tagLabel;
tagLabel = // I want get one subview in view where tag = 1 
Run Code Online (Sandbox Code Playgroud)

请帮我理解如何做到这一点.

objective-c uiview uilabel

27
推荐指数
5
解决办法
5万
查看次数

如何在滚动时在UIScrollView中移动一个方向

我是Objective-c的新手.我创建了UIScrollView对象并使用以下代码添加到我的视图中:

height = self.view.frame.size.height;
width = self.view.frame.size.width;

scrollbar = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
scrollbar.delegate = self;
scrollbar.backgroundColor = [UIColor whiteColor];
scrollbar.maximumZoomScale = 1.0;
scrollbar.minimumZoomScale = 1.0;
scrollbar.clipsToBounds = YES;
scrollbar.showsHorizontalScrollIndicator = YES;
scrollbar.pagingEnabled = YES;
[scrollbar setContentSize:CGSizeMake(width*4, height*4)];
[self.view addSubview:scrollbar];

for (int i = 1; i <= 4; i++) {
    first = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
    first.view.frame = CGRectMake((i-1)*width, 0, width, height*4);
    [scrollbar addSubview:first.view];

    switch (i) {
          ase 1:
              first.view.backgroundColor = [UIColor blueColor];
              break;
          case 2:
              first.view.backgroundColor …
Run Code Online (Sandbox Code Playgroud)

objective-c uiscrollview ios

3
推荐指数
1
解决办法
2064
查看次数

如何检测NSArray中有多少相同的对象

我有一个NSArray,我想知道它有多少特定的对象?

这是我的代码:

NSArray *filter = [[NSArray alloc]initWithObjects:@"1",@"2",@"2",@"3",@"2",@"3", nil];

switch (section) {
      case 0:
          //check how many 1 object is filter array
          return //number of 1 object
          break;
      case 1:
          //check how many 2 object is filter array
          return //number of 2 object
          break;
      case 2:
          //check how many 3 object is filter array
          return //number of 3 object
          break;
}
Run Code Online (Sandbox Code Playgroud)

请指导我.

objective-c nsarray ios

-1
推荐指数
1
解决办法
1013
查看次数

标签 统计

objective-c ×3

ios ×2

nsarray ×1

uilabel ×1

uiscrollview ×1

uiview ×1