Iphone NSMutableArray,NSMutableDictionary AND 动态添加按钮
一.NSMutableDictionary?
NSMutableDictionary? * tags;
1.NSMutableDictionary 添加內(nèi)容:
[tags setValue:xxx forKey :xxx];
2.NSMutableDictionary 遍歷:
for(NSString * title in tags){
?? //其中得到的title是key
}
3.NSMutableDictionary 根據(jù)key取得value:
[tags valueForKey :xxx];
二.NSMutableArray
NSMutableArray *buttons;
1.NSMutableArray添加內(nèi)容:
[buttons addObject:xxx];
2.NSMutableArray遍歷:
for(xxxx *button in buttons){
}
三.動(dòng)態(tài)添加按鈕到view以及添加按鈕點(diǎn)擊事件:
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];
總結(jié)
以上是生活随笔為你收集整理的Iphone NSMutableArray,NSMutableDictionary AND 动态添加按钮的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iphone UITableView及U
- 下一篇: iphone开发如何隐藏各种bar