0
我是新來的我的手機programming.I已創建自定義按鈕裏面,我附加每個自定義按鈕的圖像。現在,自定義按鈕圖像顯示在縮略圖中。現在我想要什麼,如果我選擇任何縮略圖圖像或自定義按鈕。在這裏我想選擇和取消選擇縮略圖圖像,我想存儲選定的圖像標籤值在array.How這樣做下面我的代碼使用下面的代碼我創建自定義按鈕並將圖像附加到自定義按鈕。如何選擇和取消選擇縮略圖圖像和所選圖像存儲陣列中的iphone
blaukypath =[[NSMutableArray alloc]init];
for (NSString* path in array)
{
[blaukypath addObject:[UIImage imageWithContentsOfFile:path]];
NSLog(@"%@",path);
}
myScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 840.0)];
myScrollView.delegate = self;
myScrollView.contentSize = CGSizeMake(320.0, 840.0);
myScrollView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:myScrollView];
float horizontal = 8.0;
float vertical = 8.0;
for(int i=0; i<[blaukypath count]; i++)
{
if((i%4) == 0 && i!=0)
{
horizontal = 8.0;
vertical = vertical + 70.0 + 8.0;
}
buttonImage = [UIButton buttonWithType:UIButtonTypeCustom];
[buttonImage setFrame:CGRectMake(horizontal, vertical, 70.0, 70.0)];
[buttonImage setTag:i];
[buttonImage setImage:[blaukypath objectAtIndex:i] forState:UIControlStateNormal];
[buttonImage addTarget:self action:@selector(buttonImagePressed:) forControlEvents:UIControlEventTouchUpInside];
[myScrollView addSubview:buttonImage];
horizontal = horizontal + 70.0 + 8.0;
}
[myScrollView setContentSize:CGSizeMake(320.0, vertical + 78.0)];
[self.myScrollView addSubview:buttonImage];
現在,如果選擇我想選擇和取消選擇的縮略圖圖像和選擇的縮略圖圖像,我想在數組來存儲任何縮略圖圖像。
-(void)buttonImagePressed:(id)sender
{
UIButton *btn = (UIButton*)sender;
if (btn.tag==0)
{
[btn setImage:[UIImage imageNamed:@"Default.png"] forState:UIControlStateNormal];
btn.tag=1;
}
else{
[btn setImage:nil forState:UIControlStateNormal];
btn.tag=0;
}
一些機構告訴記者,通過上面的代碼,我將工作,但我不工作正是我want.i要選擇和取消選擇,也選擇的圖像,我想在陣列存儲。 感謝 阿斯拉姆
謝謝你給replay.its working..canü請告訴我,我怎麼能存儲陣列 – Mohammed 2013-03-19 07:15:30
裏面我已經編輯入圍標記按鈕值我的answer.plz檢查它 – 2013-03-19 12:52:19
非常感謝你的工作...... – Mohammed 2013-03-19 14:22:09