добавление изображений в верхней части кнопки, которая находится на прокрутке - PullRequest
0 голосов
/ 07 ноября 2011
NSData *data = [NSData dataWithContentsOfFile:@"path of XML"];
NSError *error = nil;
GDataXMLDocument *document = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error];
NSError *err=nil;
NSArray *nodes = [document nodesForXPath:@"/product_list/product[category = \"Pins & Collectibles\"]/image" error:&err]; 
NSMutableArray *array =[[NSMutableArray alloc]initWithCapacity:[nodes count]];

for(int i=0;i<[nodes count]; i++)
{
    [array addObject:(NSString *)[[(NSString *)[[(NSString *)[[[NSString stringWithFormat:@"%@",[nodes objectAtIndex:i]] componentsSeparatedByString:@"{"] objectAtIndex:1] componentsSeparatedByString:@"<image>"] objectAtIndex:1] componentsSeparatedByString:@"</image>"] objectAtIndex:0] ]; 
}

NSLog(@"%@",array);

В массиве есть все изображения, которые мне нужны, чтобы поместить его поверх кнопки

Ответы [ 2 ]

1 голос
/ 07 ноября 2011

Это может работать:

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundImage:[UIImage imageWithData:IMAGE_DATA] forState:UIControlStateNormal];
0 голосов
/ 07 ноября 2011

Затем создайте цикл for в этом

for(int i=0;i<100;i++)
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setBackgroundImage:[UIImage imageWithData:IMAGE_DATA] forState:UIControlStateNormal];
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...