Iphone NSMutableArray,NSMutableDictionary AND 动态添加按钮
一.NSMutableDictionary
NSMutableDictionary * tags;
1.NSMutableDictionary 添加内容:
[tags setValue:xxx forKey :xxx];
2.NSMutableDictionary 遍历:
for(NSString * title in tags){
//其中得到的title是key
}
3.NSMutableDictionary 根据key取得value:
[tags valueForKey :xxx];
二.NSMutableArray
NSMutableArray *buttons;
1.NSMutableArray添加内容:
[buttons addObject:xxx];
2.NSMutableArray遍历:
for(xxxx *button in buttons){
}
三.动态添加按钮到view以及添加按钮点击事件:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
CGRect frame = CGRectMake(0,0,300,20);
[button setFrame:frame];
[button setTitle:@"xxx" forState:UIControlStateNormal];
[button addTarget:self action:@selector(xxxx) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
总结
以上是生活随笔为你收集整理的Iphone NSMutableArray,NSMutableDictionary AND 动态添加按钮的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: iphone UITableView及U
- 下一篇: iphone开发如何隐藏各种bar