开发者

How to make custom album view ? OR how to store RSS feed Image in album

开发者 https://www.devze.com 2023-02-05 00:52 出处:网络
hey i get lots of image from RSS Than i have to display all that image as album and i have no idea hot set all in album...

hey i get lots of image from RSS Than i have to display all that image as album and i have no idea hot set all in album...

i think make custom album using Table View is that proper way but i am little bit confuse than after how to get proper click of particular image from one row...

in my custom cell i put three imageView...

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

appDeleg = (NewAshley_MedisonAppDelegate *)[[UIApplication sharedApplication] delegate];
static NSString *CellIdentifier = @"Cell";


MyCustomCell *cell = (MyCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"MyCustomCell" 
                                  owner:self options:nil];

    cell = mycustomcell;
    self.mycustomcell = nil;
}



int index = indexPath.row;
imageData *objImage = [appDeleg.downloadImageData objectAtIndex:index];
[[cell imgView1] setImage:objImage.image1];

imageData *objImage = [appDeleg.downloadImageData objectAtIndex:index + 1];
    [[cell imgView2] setImage:objImage.image2];

    imageData *objImage = [appDeleg.downloadImageData objectAtIndex:index + 2];
    [[cell imgView3] setImage:objImage开发者_如何学Go.image3];


return cell;

}

// in Next loop i got index 1 so for that i find way add each time series like 1,3,5,7... so i got but i don`t get idea how to i set that (how to perform this logic in objective C)


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:                   (NSIndexPath *)indexPath {

      static NSString *CellIdentifier = @"Cell";

// CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

      cell = [[[UITableViewCell alloc]        initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

}
// Configure the cell...
ImageData * objImage1 = [[ImageData alloc] init];


cell.selectionStyle = UITableViewCellSelectionStyleNone;
int n = indexPath.row * 2;

button1 = [UIButton buttonWithType:UIButtonTypeCustom];

button1 = [[UIButton alloc] initWithFrame:CGRectMake(11.0f, 0.0f,145.0f, 100.0f)];

objImage1 = [appDelg.imageArray objectAtIndex:n];
[button1 setImage:objImage1.imgData forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(buttonPressedAction:)      forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:button1];

if(n+1 < [appDelg.imageArray count]){
button2 = [UIButton buttonWithType:UIButtonTypeCustom];
objImage1 = [appDelg.imageArray objectAtIndex:n+1];

button2 = [[UIButton alloc] initWithFrame:CGRectMake(162.0f, 0.0f,145.0f, 100.0f)];
[button2 setImage:objImage1.imgData forState:UIControlStateNormal];
//[button1 setTitle:@"Do Stuff" forState:UIControlStateNormal];
[button2 addTarget:self action:@selector(buttonPressedAction:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:button2];
}
else {
    button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2 = [[UIButton alloc] initWithFrame:CGRectMake(162.0f, 0.0f,145.0f, 100.0f)];
    [button2 setImage:[UIImage imageNamed:@"white.png"] forState:UIControlStateNormal];
    [button2 setEnabled:YES];
    [button2 setSelected:NO];
    button2.alpha = 1.0;
    [cell addSubview:button3];
}

return cell;
}

And My Two Method for Images....

- (void)buttonPressedAction:(id)sender
 {
    button1 = (UIButton *)sender;

    UITableViewCell *cell = (UITableViewCell*)[button superview];
    int row = [tblView indexPathForCell:cell].row;
     int n = row * 2;
    NSLog(@"Button Pressed %d", n);
    NSString *str = [NSString stringWithFormat:@"%d",n+1];
    objImage = [[ShowImage alloc] initWithNibName:@"ShowImage" bundle:nil];
   [objImage imageSelect:n :str];
   [self.view.window addSubview:objImage.view];

 }

I tried this with UIIMage view but in that case i don`t get button id in my Tap action....

  button2 = (UIButton *)sender;

  UITableViewCell *cell = (UITableViewCell*)[button2 superview];
  int row = [tblView indexPathForCell:cell].row;

my application Crash on second line of above code .....

BUT no Problem with button application goes smooth....

0

精彩评论

暂无评论...
验证码 换一张
取 消