【问题标题】:Assign UIButtons Titles of NSMutableArray To UIButtons of NSMutableArray?将 NSMutableArray 的 UIButtons 标题分配给 NSMutableArray 的 UIButtons?
【发布时间】:2012-05-16 07:31:39
【问题描述】:

我有两个 NSMutableArray。我的第一个数组包含 3 个 UIButtons 以及按钮标题,我的第二个数组包含 50 个 UIButtons。但是所有这 50 个 UIButtons 都有随机字母作为标题。这是我的第一个数组代码。

  NSMutableArray *buttons = [NSMutableArray arrayWithObjects:btn1, btn2, btn3, nil];
        [btn1 setTitle:@"stack" forState:UIControlStateNormal]; 
        [btn2 setTitle:@"over" forState:UIControlStateNormal]; 
        [btn3 setTitle:@"flow" forState:UIControlStateNormal]; 

现在我想将我的第一个按钮标题“堆栈”分配给使用索引 3-7 的第二个数组按钮。第二个按钮标题“结束”到使用索引 15-18 的第二个数组按钮和第三个按钮标题使用索引 30-33 “流”到第二个数组按钮。请任何人为我提出一个解决方案。谢谢

【问题讨论】:

标签: iphone objective-c ios uibutton nsmutablearray


【解决方案1】:
for (int i=3; i<=7; ++i) {
    UIButton *temp = [stack objectAtIndex:i];
    [temp setTitle:@"Temp" forState:UIControlStateNormal];

作为一个例子。现在重复你的其他索引:)

【讨论】:

  • Thanx @Martol 1ni 快速响应。你的代码解决了我的索引问题。但是如果你检查这个链接,那么我希望你能理解我的问题。Thanx stackoverflow.com/questions/10596414/… -
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-16
  • 2017-04-22
  • 1970-01-01
  • 1970-01-01
  • 2013-05-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多