#pragma mark load filePath
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"tabs" ofType:@"cfg"];
if (filePath) {
NSString *myText = [NSString stringWithContentsOfFile:filePath];
NSMutableArray *a1 = [[NSMutableArray alloc] init];
[a1 addObjectsFromArray:[myText componentsSeparatedByString:@"\n"]];
[a1 addObject:myText];
NSUInteger i;
for (i = 1; i <= [a1 count]-1; i++)
{
NSString *urlE=[a1 objectAtIndex:1];
NSLog(@"url is %@",urlE);
#pragma mark buttons
CGRect frame = CGRectMake(curXLoc, 10, 60, 30);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = frame;
button.tag=i;
[button setImage:[UIImage imageNamed:@"tab2.png"] forState:UIControlStateNormal];
[button setTitle:(NSString *)@"new button" forState:(UIControlState)UIControlStateNormal];
[button addTarget:self action:@selector(buttonEvent:) forControlEvents:UIControlEventTouchUpInside];
curXLoc += (kScrollObjWidth1);
[self.view addSubview:button];
}
}
}
-(void)buttonEvent:(UIButton*)sender{
NSLog(@"new button clicked!!!");
if (sender.tag == 1) {
NSLog(@"1");
}
if (sender.tag == 2) {
NSLog(@"2");
}
}
No comments:
Post a Comment